This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes background and foreground color is not changing in full screen window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "background and foreground color is not changing in full screen window" Watch "background and foreground color is not changing in full screen window" New topic
Author

background and foreground color is not changing in full screen window

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
why my background and foreground color is not changing??

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Please post an SSCCE. Right now I get compiler errors about missing class "Screen". Since that's doing the actual full screen handling we can't test anything.

That said, overriding the paint method is the AWT way to go. In Swing you override paintComponent. However, JFrame (and JWindow and JDialog) don't have that method; instead you should set its content pane to be some container (usually JPanel) that does override paintComponent.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
sorry for not posting the sscce code, here is that, and i also changed my code as you said, although after overriding paintComponent i am able to get background color, but text is not visisble.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

You're still overriding paint. Like I said, you should override paintComponent instead:
After a short black screen I now get a pink-ish background with grey letters "This is FullScreen".
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
okay i was not doing this
super.paintComponent(g);
therefore i was not getting it...

Thank you.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

You're welcome.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: background and foreground color is not changing in full screen window