How to check that a JCheckBox is checked?

oneat picture oneat · Aug 30, 2010 · Viewed 135.4k times · Source

How can I check if a JCheckBox is checked?

Answer

Matthew Flaschen picture Matthew Flaschen · Aug 30, 2010

Use the isSelected method.

You can also use an ItemListener so you'll be notified when it's checked or unchecked.