I'm trying to listen for events on a single Frame
via WindowStateListener
.
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowStateListener;
import java.awt.event.WindowEvent;
public class UserInterface implements WindowStateListener
{
public static void main(final String[] arguments)
{
UserInterface userInterface = new UserInterface();
}
public UserInterface()
{
Frame frame = new Frame("Graphics Example");
frame.addWindowStateListener(this);
frame.add(new Label("Hello, world!");
frame.pack();
frame.setVisible(true);
}
public void windowStateChanged(WindowEvent event)
{
System.out.println(event.paramString();
}
}
It's working fine for minimization events, but not close events. WINDOW_CLOSING
is definitely a valid WindowEvent
value, and it's definitely something that Frame
can throw. So why isn't it being passed to windowStateChanged()
?