8
RADIO BUTTONS AND CHECK BOXES By: Stag and Fish; Party Animals

By: Stag and Fish; Party Animals. Radio buttons are a way of letting users choose only one option of a list

Embed Size (px)

Citation preview

Page 1: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

RADIO BUTTONS AND CHECK BOXES

By: Stag and Fish; Party Animals

Page 2: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

Radio Buttons

Radio buttons are a way of letting users choose only one option of a list

Page 3: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

Uses of Radio Buttons

Uses: Surveys Multiple choice questions terms of service

Page 4: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

How to create Radio Buttons

They are created by implementing `JRadioButton` and grouping the buttons into a `ButtonGroup`

public class Demo extends JPanel                                                                 implements ActionListener {                //Create a set of private reusable variables        private String button1 = “Choice 1";                 public Demo () {                        super(new BorderLayout()); //I have no idea what this does                                            //Create Choice 1                    JRadioButton button1 = new JRadioButton(Choice 1);

Page 5: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

Check Boxes

Check boxes are a way to allow users to select multiple options from a list

Page 6: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

Uses of Checkboxes

Uses: Surveys with many applicable choices Select all that apply Choosing items from a list

Page 7: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

How to create Checkboxes

Check boxes are created using JCheckBox items with unique names

public class Checkboxes extends JPanelimplements ItemListener {

private JCheckBox b1; public Checkboxes() { super(new BorderLayout()); //This is a mystery //Create the check boxes. b1 = new JCheckBox("Do not uncheck!"); b1.setSelected(true);

Page 8: By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list

Sources

Java Docs