Java Radio Buttons

Discussion in 'Java' started by bwilde@gmail.com, Jun 30, 2005.

  1. Guest

    Hello,

    I am creating a GUI in Java and would like to make buttons that behave
    like radio buttons but look like regular JButtons. That is, I would
    like for there to be a button group of three rectangular buttons, with
    one of them always selected (and displayed differently as the other
    to). When another button is clicked, I would like to unselect the
    previous one and select the current one.

    The closest thing that I have seen to do this is to play around with
    the icons that are used for radio buttons (although I don't think that
    java lets me add new text to these images). It seems like there should
    be a simpler way of doing this, though.

    Any thoughts?

    Thanks.
    , Jun 30, 2005
    #1
    1. Advertising

  2. Lee Weiner Guest

    In article <>,
    wrote:
    >Hello,
    >
    >I am creating a GUI in Java and would like to make buttons that behave
    >like radio buttons but look like regular JButtons. That is, I would
    >like for there to be a button group of three rectangular buttons, with
    >one of them always selected (and displayed differently as the other
    >to). When another button is clicked, I would like to unselect the
    >previous one and select the current one.
    >
    >The closest thing that I have seen to do this is to play around with
    >the icons that are used for radio buttons (although I don't think that
    >java lets me add new text to these images). It seems like there should
    >be a simpler way of doing this, though.



    There is. If you use JToggleButtons and add them to a ButtonGroup, they will
    look like JButtons and act like JRadioButtons.

    Lee Weiner
    lee AT leeweiner DOT org
    Lee Weiner, Jun 30, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott D Johnson
    Replies:
    1
    Views:
    1,036
    Scott D Johnson
    Sep 27, 2006
  2. Jan C. Faerber
    Replies:
    0
    Views:
    606
    Jan C. Faerber
    Jun 30, 2009
  3. Hiten
    Replies:
    1
    Views:
    600
    Vidar Petursson
    May 26, 2004
  4. Dr. Leff
    Replies:
    3
    Views:
    276
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    206
    David Mark
    Oct 15, 2007
Loading...

Share This Page