aspose file tools
The moose likes Applets and the fly likes AWT Background Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "AWT Background Problem" Watch "AWT Background Problem" New topic
Author

AWT Background Problem

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 348
When I first bring up the web page, I get the wrong background color (it's actually the foreground color - black - instead, although that might be coincidence). Refreshing the page makes the background of the applet area the same color as the HTML page background. Then, when I go to another tab and return, the background of the applet area is whatever was in that area on the page of the last tab that I visited. I actually wouldn't mind if the background in the applet area was transparent right to the background of the HTML page, but only the HTML page in which is resides - not wherever I was before ...




Correlation does not prove causality.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 348
The problem occurred using Firefox, but was not repeatable in Opera. So, I'm guessing it's a Firefox bug. Anyone concur ? Disagree?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Anyone concur ? Disagree?

to concur/disagree you would need to post the 'exact' code/steps that reproduces the problem.

lines in the code like this

.....

do not help
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 348



Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8438

1) You extend JApplet. In such scenarios (where you use Swing components) it is recommended to override paintComponent() for custom painting
2) In the init() you are invoking setBack/Foreground(). Later on you are also calling g2.fill. What exactly are you trying to do here?
3) Your class has a main method? Who is supposed to be invoking that?
4) Your main method creates a JFrame and you add an applet instance to it? What exactly are you trying to do here?

Recommended reading: http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
running the code, I see the same problem in Firefox,
which seems to be resolved by adding the indicated line

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 348
Great! Thanks! ...... Now, why doesn't it work in Opera? (No change in config, etc.)

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

That last error is not UI related anymore but is specific to applets. Since the UI problem is solved I'll move this thread to our Applets forum.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: AWT Background Problem
 
Similar Threads
convert swing to applet
JMenuBar on the move
Converting an Application into JApplet
ListCellRenderer!!!Help!!
Problem while Invoking Applet's method from javascript