Solved

How to change background color

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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.

718 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