wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 928
why my background and foreground color is not changing??

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

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: 928
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: 19538
    
  16

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: 928
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: 19538
    
  16

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: background and foreground color is not changing in full screen window
 
Similar Threads
nullPointerException found regarding Window
Images don't painting
Developing Games In Java chapter 2 example not doing as i would have expected
background color is not changing?
Java Tetris