Hey guys so I'm making this simple movie ticketing system My program flow is as follow and all pages are in different JFrames: Main Menu>Choose Day>Select movie>select seat>back to MainMenu
I'm using JToggle
in the seat chooser. Is it possible to disable the toggle button throughout entire execution once selected? I'm using JToggleButton.setEnabled(false);
but everytime I go back to menu and come back to seat chooser,the button is still not disabled .what I want to do is to have it disable even after I'm back to MainMenu, so when I go back to seat chooser, I can't select this seat anymore.
Below are some codes in it:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
MainSelection s = new MainSelection();
s.setVisible(true);
if(jToggleButton1.isSelected())
{
jToggleButton1.setEnabled(false);
}
if(jToggleButton2.isSelected())
{
jToggleButton2.setEnabled(false);
}
if(jToggleButton3.isSelected())
{
jToggleButton3.setEnabled(false);
}
}
Please check it out
You seem to be re-creating the GUI that displays your toggle buttons each time it is displayed, and you should not be doing this.
Instead
setVisible(true)
.setVisible(false)
.Specifically:
Edit
You ask:
You are doing something like:
And I'm recommending that instead you do:
Also, you should do something about that duplicate post of yours: