Results 1 to 7 of 7
  1. #1
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Question Radio Buttons - Reset - clear dot

    I have 5 radio buttons in my gui, I have a reset button which I have resetting everything else but now I am looking to remove the dot from the selected RB when you press the reset.

    Is this possible?

    and if so could someone assist me with how?

    Thanks in advance.

  2. #2
    DiamondDog is offline Member
    Join Date
    Aug 2009
    Posts
    18
    Rep Power
    0

    Default

    Within the reset button's click handler, can you not just do this:

    Java Code:
    myRadioButton1.setSelected(false);
    myRadioButton2.setSelected(false);
    myRadioButton3.setSelected(false);
    myRadioButton4.setSelected(false);
    myRadioButton5.setSelected(false);
    ?
    Last edited by DiamondDog; 10-14-2009 at 12:39 AM.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    If the JRadioButtons all share the same ButtonGroup, Java 1.6 allows you to clear the selection by a method in ButtonGroup which I can't remember for the moment, but if you look up the ButtonGroup API (again for Java 1.6), you will find it.

    edit: Looked it up and it's clearSelection(). ButtonGroup#clearSelection()

    If you have Java 1.5 or earlier, I've heard of some clearing the selection by creating an extra non-visualized (ghost) JRadioButton, and selecting it.
    Last edited by Fubarable; 10-14-2009 at 01:03 AM.

  4. #4
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Default removing dot from radio button on reset button

    I have just tried your suggestion but the dot is still left in the radio button, I have tried searches etc and cannot come up with anything that will do this.

    Like I say I don't know if it is possible to do what I want.

    Thanks in advance

  5. #5
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Default

    Fubarable, thanks, ill take a look.

  6. #6
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Thumbs up

    Fubarable, thanks, it worked

    Java Code:
    buttonGroup1.clearSelection();

  7. #7
    Yudhizth is offline Member
    Join Date
    Jun 2014
    Posts
    1
    Rep Power
    0

    Default Re: Radio Buttons - Reset - clear dot

    Thanks for this question and for Fubarable's answer

Similar Threads

  1. Java Radio Buttons
    By dbashby in forum New To Java
    Replies: 4
    Last Post: 09-21-2009, 01:07 AM
  2. Deselect Radio Buttons
    By linux1man in forum AWT / Swing
    Replies: 7
    Last Post: 03-21-2009, 05:01 AM
  3. How to use Radio Buttons
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 03:26 PM
  4. radio buttons and paint
    By gtraylo in forum Java Applets
    Replies: 1
    Last Post: 04-19-2008, 01:43 PM
  5. property for radio buttons
    By swapnanair in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 12-03-2007, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •