Hi,
I'm writing a basic swing program and need a button which will alternate between two values. Each value will then be added to the text label beneath the button.
eg: press the button the first time and the text beneath will write 'Increment'. Press the button again and it will write 'Decrement', and so on.
I know how to output one value to a label, but I'm not certain how to get the button to alternate between the two values.
My current code is as follows,
static private class IncrementDecrementAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
SwingApplication2.label.setText(labelPrefix + "Increment");
//SwingApplication2.label.setText(labelPrefix + "Decrement");
}
}
Any ideas how I can change this to include alternating between 'Increment' and 'Decrement'.
Thanks