• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AWT Background Problem

 
Ranch Hand
Posts: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great! Thanks! ...... Now, why doesn't it work in Opera? (No change in config, etc.)

 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic