I have an array of JTogglebuttons and a JButton, when the JButton is pressed it initiates a loop that iterates through all the JTogglebuttons to see if it is pressed, and if it is it should make it disable/unclickable
Here is the snippet of code that is an issue
Public void actionPerformed(ActionEvent e){
Object pressed = e.getSource();
if (pressed == btnPurchase) {
for(int row = 0; row<8 ; row++){
for(int column = 0; column < 4; column++) {
if (seat[row][column].isPressed()) {
seat[row][column].setEnabled(false);
}
}
}
}
I get this error
cannot find symbol
symbol : method isPressed()
location: class javax.swing.JToggleButton
if (seat[row][column].isPressed()) {
If i use .isSelected
i get
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at cinemaManager.actionPerformed(cinemaManager.java:174)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6375)