I have two cards in a cardlayout and a button that allows one to go back and forth. How can I make the button inactive once it is clicked once so that the user can't go back to the previous card?
Asked
Active
Viewed 64 times
4 Answers
2
You can disable the button (in your action listener)
button.setEnabled(false);

objects
- 8,637
- 4
- 30
- 38
2
To make a button inactive, do:
JButton b = new JButton("BUTTON");
b.setEnabled(false);
and the button will not accept clicks.

Java42
- 7,628
- 1
- 32
- 50
2
You could add an event handler to the click event of the button and disable it with button.setEnabled(false);
in the event handler.

joshuahealy
- 3,529
- 22
- 29