I noticed that when my program's GUI (using JFrame) window is minimized and then maximized, the frame contents get erased. Only the buttons reappear as the mouse moves over them.
I tried adding a WindowListener to JFrame and extending an internal class from WindowAdapter containing the following action method:
public class ListenForMaximize extends WindowAdapter { public void windowActivated(WindowEvent e) { mainFrame.invalidate(); mainFrame.validate(); mainFrame.repaint(); System.out.println("Received event"); } }
The "Received Event" println is simply for testing purposes. It prints both when the program is opened and when it is maximized from the taskbar. But, the frame still remains erased. What else do I need to add to the method? Is validating and repainting not the right course of action?
Thanks in advance