Solved

How to change background color

Posted on 1998-04-10
3
408 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 20 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 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 tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now