Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to change background color

Posted on 1998-04-10
3
Medium Priority
?
418 Views
Last Modified: 2010-04-16
This question is very simple, but I have searched in many documents, and I haven't found the answer. I need to change the gray background to a transparent one in my Applet. How can I do that? what method do I have to use?

Thanks in advance,
Jaime
0
Comment
Question by:DaThiN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 80 total points
ID: 1234016
Transparent backgrounds are a GIF file format property, not a windows.

An applet is a window that is running on an independant thread from the browser but maintains an intr process communication channel with the browser that invoked it.

So, your question is realy, how can I make a transparent window, and the answer is that you cant.

What you can do though is to place a canvas that covers the entire surface of the applet window and load an image that contains the section of the background that you want place on it.

Since controls can be placed over a canvas you can, with a little work, obtain the same effect.
0
 

Author Comment

by:DaThiN
ID: 1234017
Thanks for the answer... now I have a problem with the canvas. I have the following in my paint( ) method (example taken from my book):


            Canvas c = new Canvas( );
            Image off = c.createImage( 200, 100 );
            Graphics offg = off.getGraphics( );

and after drawing offline, I have:
     
                                    g.drawImage( off, 0, 0, this );

When debugging, I verify that "off" contains "null" upon return from the createImage( ) method. Any suggestion?

Thanks
Jaime


0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1234018
Use MediaTracker to load the graphics.

Take a look at ch.2 of the online book:

Tricks of the Java Programming Gurus
by Glenn L. Vanderburg. et al.

at http://www.mcp.com

under the personal Bookshelp Programming Language library section. (Registration is free).

You will find all the docs and sample code you could need there.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question