Solved

How to change background color

Posted on 1998-04-10
3
412 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTPSessionBindingListernter not configured in deployment descriptor 2 65
table example 4 32
iterator/ListIterator approach 17 39
java mysql insert application 14 28
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

838 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