Re: checkboxes and netbeans
You haven't said what GUI component you are using so I am assuming it is a JCheckBox.
The ActionEvent object contains a reference to the object that generated the event - in this case your JCheckBox. You can get the component by calling getSource(). So now you know which component generated the event you can find out if it is selected and set the label accordingly. JCheckBox has an isSelected() method so you could use something like
Code:
JCheckBox myComponent = (JCheckBox)evt.getSource();
lblShowText.setVisible(myComponent.isSelected());
Note: this assumes only JCheckBox components will generate events that are passed to this method.
Re: checkboxes and netbeans
I'm sorry about not being clearer about what components I was using... :blush:
Yes, it was a checkbox and this code fixed it!! Thank you so much, keang!!!
:D :D :D
For anyone else looking at this thread: Since I am using Netbeans GUI creator, I did not have to declare the JCheckBox component so it was one line of code I had to rewrite.