Skip to content

Multiple Choice Class

Mohammad Mahfooz edited this page Mar 10, 2023 · 3 revisions

MultipleChoiceButton

The MultipleChoiceButton class is a custom button that extends the SelectionButton class. It is used to represent a multiple-choice selection button.

Constructors

  • MultipleChoiceButton(String text): Creates a new MultipleChoiceButton with the given text.

Methods

  • void switchSelected(): Changes the selected state of the button. If the button is being selected, it also deselects all other SelectionButtons in the same parent container.

Example Usage

MultipleChoiceButton button = new MultipleChoiceButton("Choice 1");
button.setSelected(true);
button.addActionListener(e -> {
    System.out.println("Button clicked");
});
Clone this wiki locally