I have a button that opens up a frame. Is there a way to enable/disable a button depending on whether the frame is open?
Let's say, if the frame is open, I would like the button to be button.enabled(false)
. But as soon as the frame is closed, I would like to change it to button.enabled(true)
.
In my actionPerformed method of the button I do this
JFrame testFrame = new JFrame();
testFrame.setSize(100,100);
testFrame.setVisible(true);
However, I don't want to open up more than one of these frames at a time. So while the frame that is created by the click of the button is open, I want the button disabled until the frame is closed. (Even if the frame is not visible, I still don't want to allow another one to be opened)