By Tony Bevis on Thursday, 19 October 2023
Category: Java

Java programming course: 14.6 JCheckBox

Previous lesson: 14.5 JButton

Course contents 

JCheckBox

The JCheckBox class allows the entry of values which are true or false by enabling the user to click a small rectangular box resulting in a "tick" mark being displayed within:

The screen will look like this:

Each time the user clicks inside the check box it will alternate between being ticked and un-ticked. If you want to make the box ticked in your program, you can use the setSelected() method:


To see whether or not the check box is checked you can use the isSelected() method which returns a boolean:

Next lesson: 14.7 JRadioButton

Related Posts

Leave Comments