• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AWT Background Problem

 
Roger F. Gay
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...



 
Roger F. Gay
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! Thanks! ...... Now, why doesn't it work in Opera? (No change in config, etc.)

 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic