Results 1 to 5 of 5

Thread: How to Use the ButtonGroup Component in Java?

  1. #1
    Join Date
    Aug 2006
    Posts
    332

    How to Use the ButtonGroup Component in Java?

    Hello,
    I am creating a project which is my assignment. I have done lot of things into that, but I am not able to use the buttongroup. I have tried to do lot of things but I am not getting the desired output. So thought posting here would be helpful for me. Please tell me how to use the ButtonGroup Component in Java.?? Any coding related to the topic would be grateful.!!
    Do not email me asking for tech support. Any private support is billable at $50 an hour.

  2. #2
    Join Date
    Jul 2006
    Posts
    289

    Re: How to Use the ButtonGroup Component in Java?

    I think that before using the ButtonGroup Component, you should have enough knowledge about it. Once you clear the concepts, then it would be easy for you while going through the code. Otherwise, you will find tough when you see the coding. So, I thought to explain you more about the components. The ButtonGroup component manages the selected / unselected state for a set of buttons. When there is a group, ButtonGroup instance guarantees that only one button can be selected at a time. At the starting, all buttons managed by a ButtonGroup instance are unselected.
    Signatures reduce available bandwidth

  3. #3
    Join Date
    Mar 2008
    Posts
    349

    Re: How to Use the ButtonGroup Component in Java?

    You can use ButtonGroup with any set of objects that inherit from AbstractButton. Normally, a button group contains instances of JRadioButton, JRadioButtonMenuItem, or JToggleButton. Also keep in mind that ButtonGroup isn't a UI component, it groups buttons together conceptually. You can also create Radio Button Group Component in Java. The radio buttons are rendered in rows and columns in an HTML <table> element. The number of rows is defined by the number of radio buttons. The number of columns is defined by the columns property. The default layout is a single vertical column.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to Use the ButtonGroup Component in Java?

    For writing a code that uses a ButtonGroup component, you should follow the given steps :
    1. First you will have to create a Subclass JFrame.
    2. Then you will have to call ContextPane together with a layout manager.
    3. Then you will have to declare and configure a set of radio buttons or toggle buttons.
    4. Later, instantiate a ButtonGroup object
    5. Lastly call the add method on that buttongroup object in order to add each button to the group.

  5. #5
    Join Date
    Jul 2006
    Posts
    442

    Re: How to Use the ButtonGroup Component in Java?

    The following are the ButtonGroup API :
    1. ButtonGroup() - This method create a ButtonGroup instance.
    2. void add(AbstractButton) - This method add a button to the group, or remove a button from the group.
    3. public ButtonGroup getGroup() - By using this you can get the ButtonGroup, if any, that controls a button.
    "When they give you ruled paper, write the other way..." J.R.J.

Similar Threads

  1. How to disable component in Java Swing
    By Shaina Na in forum Software Development
    Replies: 2
    Last Post: 20-01-2012, 12:02 PM
  2. What is a EOL Component
    By Abbie in forum Monitor & Video Cards
    Replies: 6
    Last Post: 12-03-2010, 11:09 AM
  3. How to Resize a Component in Java?
    By Rob Dizzle in forum Software Development
    Replies: 4
    Last Post: 14-02-2010, 02:46 AM
  4. How to write a Component Listener in Java?
    By hariharan_00 in forum Software Development
    Replies: 4
    Last Post: 12-02-2010, 06:28 AM
  5. How to create a JList component in java?
    By KALANI84 in forum Software Development
    Replies: 4
    Last Post: 28-01-2010, 04:11 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,213,644.31949 seconds with 17 queries