Constructors of Checkbox class

Constructors

Description

Checkbox()

Creates a checkbox with no label.

Checkbox(String label)

Creates a checkbox with the specified label.

Checkbox(String label, boolean state

Creates a checkbox with the given label and sets the initial state.

Checkbox(String label, boolean state, CheckboxGroup group)

Creates a checkbox with the specified label, state, and associates it with a CheckboxGroup.

Checkbox(String label, CheckboxGroup group, boolean state)

Creates a checkbox with the given label, associates it with the specified CheckboxGroup, and sets the initial state.

Methods of checkbox class are inherited by two classes:

  • java.awt.Component
  • java.lang.Object

Java AWT Checkbox

Java AWT (Abstract Window Toolkit) provides a really various set of tools for edifice in writing user interfaces (GUIs), and among these tools is the Checkbox class. Checkboxes are necessary components for user interactions, allowing users to work binary choices easily. In this clause, we’ll search the Checkbox class, its constructors, and methods, and supply examples of creating checkboxes with really different logic.

Similar Reads

Java AWT Checkbox Class Declaration

The Checkbox class in Java AWT is secondhand to create checkboxes, which represent options that users can either select or deselect. Clicking on a checkbox toggles its submit between “on” (selected) and “off” (deselected)....

Constructors of Checkbox class

...

Key Methods of Checkbox class

Method Description void addItemListener(ItemListener IL) Adds the specified item listener to receive events when the state of the checkbox changes. AccessibleContext getAccessibleContext() Retrieves the accessible context for enhanced interaction with assistive technologies for the checkbox. void addNotify() Creates the peer of the checkbox for rendering purposes. CheckboxGroup getCheckboxGroup() Retrieves the associated CheckboxGroup to which the checkbox belongs. ItemListener[] getItemListeners() Returns an array of registered item listeners responsible for handling item events of the checkbox. String getLabel() Retrieves the label associated with the checkbox. T[] getListeners(Class listenerType) Returns an array containing the label of the checkbox if it is selected; otherwise, returns null. boolean getState() Returns true if the checkbox is in the selected state; otherwise, returns false. protected String paramString() Generates a string representation of the state and properties of the checkbox. protected void processEvent(AWTEvent e) Processes the general events occurring on the checkbox. protected void processItemEvent(ItemEvent e) Processes the item events occurring in the checkbox by dispatching them to registered ItemListener objects. void removeItemListener(ItemListener l) Removes the specified item listener to stop receiving item events from the checkbox. void setCheckboxGroup(CheckboxGroup g) Sets the checkbox’s group to the specified CheckboxGroup. void setLabel(String label) Sets the label of the checkbox to the specified string argument. void setState(boolean state) Sets the state of the checkbox to the specified state, either selected (true) or deselected (false)....

Example of Java AWT Checkbox

Example 1:...