The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing  [141 examples] > JCheckBox  [4 examples]

e753. Getting and Setting the State of a JCheckbox Component

    // To create a checkbox, see e752 Creating a JCheckbox Component
    
    // Get the current state of the checkbox
    boolean b = checkbox.isSelected();
    
    // Set the state of the checkbox to off
    checkbox.setSelected(false);
    
    // Set the state of the checkbox to on
    checkbox.setSelected(true);

 Related Examples
e752. Creating a JCheckbox Component
e754. Adding an Icon to the Label of a JCheckBox Component
e755. Customizing the Icons in a JCheckBox Component

See also: Actions    JButton    JComboBox    JDesktop and JInternalFrame    JFrame, JWindow, JDialog    JLabel    JList    JProgressBar    JRadioButton    JScrollPane    JSlider    JSpinner    JSplitPane    JTabbedPane    JToolBar    Keystrokes and Input Maps    Layout    Look and Feel    Menus    Progress Monitor    The Screen    Tool Tips    UI Default Values   


© 2002 Addison-Wesley.