0

I have a JFrame with an image as background,called setUndecorated and setWindowOpaque method. When I open JFrame and then let computer sleep,but when computer wake up from sleep, the JFrame becomes white.

I guess it maybe repaint problem, but I can not solve this problem, would you please give me some suggestions?

chenhai
  • 35
  • 4

1 Answers1

1

You can simply try repainting the component, that contains the image when your window (JFrame) recieves focus. That should fix the problem of repainting after "waking up" i guess.

Also you can try this:

frame.addWindowListener ( new WindowAdapter ()
{
    public void windowActivated ( WindowEvent e )
    {
        // Here repaint what you need
    }
} );
Mikle Garin
  • 10,083
  • 37
  • 59
  • First of all check if the focus-gain event is thrown or not. If thrown - repainting won't help and you will need to set frame opacity to false again or even recreate the frame (due to some bug maybe). If not - try the window listener i have added into the answer below, it might work. – Mikle Garin Apr 16 '12 at 11:19