I have a JDialog and I'd like to check whether its state is maximized, minimized or normal. How can I do that?
I have tried:
private JDialog dialog = new JDialog();
dialog.addWindowStateListener(new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
if(e.getNewState()==JFrame.MAXIMIZED_BOTH){
System.out.println(" state MAXIMIZED_BOTH");
dialog.repaint();
}
}
});
but it doesn't work of course.
Thanks
A JDialog does not show the minimize/maximize buttons. If you look here, someone asked if you could add those buttons to a JDialog and it is discouraged. It looks like if you add a WindowStateListener to a JDialog, it never gets triggered.