About JCheckBox

S

Sameer

What is the method to check whether a given JCheckButton is in selected
state or not?
I searched the API documentation for the same but was not able to find
it.

Do I have to code like following?

jcheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {

// 'selected' stuff
}
else {

// 'non selected' stuff
}
}
}
);
 
J

jan V

I searched the API documentation for the same but was not able to find it.

When searching the docs, you always need to keep in mind that whatever class
you're looking at also inherits all public and protected methods from ALL
its parent classes.

So when searching for a method you may also need to either walk the
inheritance hierarchy "up stream", or analyse the javadoc sections entitled
"Methods inherited from xxxxxxxx"
 
R

Roedy Green

What is the method to check whether a given JCheckButton is in selected
state or not?
I searched the API documentation for the same but was not able to find
it.

Checkbox uses getState and setState, where JCheckBox uses isSelected
and setSelected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top