?
Solved

How to change background color

Posted on 1998-04-10
3
Medium Priority
?
420 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

864 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