About 2,420,000 results
Open links in new tab
  1. JRadioButton | Java Swing - GeeksforGeeks

    Jun 8, 2022 · We use the JRadioButton class to create a radio button. Radio button is use to select one option from multiple options. It is used in filling forms, online objective papers and quiz. We add radio buttons in a ButtonGroup so that we can select only one radio button at a time.

  2. java - Action Listener on a radio button - Stack Overflow

    You could know which radio button is selected by the text of this button, and you could also know it by Action Command. In the oracle's radio button demo code http://docs.oracle.com/javase/tutorial/uiswing/examples/components/RadioButtonDemoProject/src/components/RadioButtonDemo.java , I learnt how to use action command.

  3. How do I get which JRadioButton is selected from a ButtonGroup

    You can put and actionCommand to each radio button (string). this.jButton1.setActionCommand("dog"); this.jButton2.setActionCommand("cat"); this.jButton3.setActionCommand("bird"); Assuming they're already in a ButtonGroup (state_group in this case) you can get the selected radio button like this:

  4. How to Use Buttons, Check Boxes, and Radio Buttons

    Radio buttons are groups of buttons in which, by convention, only one button at a time can be selected. The Swing release supports radio buttons with the JRadioButton and ButtonGroup classes. To put a radio button in a menu , use the JRadioButtonMenuItem class.

  5. java - Reading Selected Radio Button on button click - Stack Overflow

    Mar 7, 2014 · button.addActionListener(new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent arg0) { System.out.println(group.getSelection().getActionCommand()); } }); And to fix the NullPointerException, use this for all your radiobuttons:

  6. JRadioButton basic tutorial and examples - CodeJava.net

    Jul 6, 2019 · A typical usage of radio button is checking its selected state, using the isSelected() method, for example: boolean isLinuxSelected = optionLinux.isSelected(); if (isLinuxSelected) { // the Linux option is selected } else { // the Linux option is deselected }

  7. Get selected JRadioButton from ButtonGroup - Java Code Geeks

    Nov 11, 2012 · In order to get the selected JRadioButton from a ButtonGroup, one should follow these steps: Create a class that extends JFrame and implements ActionListener. Create some JRadioButtons using JRadioButton constructor, with the button’s title as an argument.

  8. How to get Value of Selected JRadioButton in Java - StackHowTo

    Aug 16, 2021 · When we click on the radio button, the actionPerformed () method is called. Use ButtonGroup.getSelection ().getActionCommand () to get the value selected by the user. import java.awt.event.*; import javax.swing.*; Output:

  9. java for complete beginners - radio buttons - Home and Learn

    Java Radio Buttons. Radio buttons are usually used to select just one item from a list, rather than the multiple items available with check boxes. Let's see how they work. Drag and drop a panel onto your form. Then locate the Radio Button control in the NetBeans palette. Drag a Radio button onto your new palette. It should look like this:

  10. JRadioButton (Java SE 11 & JDK 11 ) - Oracle

    An implementation of a radio button -- an item that can be selected or deselected, and which displays its state to the user. Used with a ButtonGroup object to create a group of buttons in which only one button at a time can be selected.

Refresh