Java JSP Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP  Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java JSP Application Hosting Web Hosting website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP,Python
Java JSP Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP, Python Java JSP Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, Python,JSP
Java JSP Application Hosting Web Hosting Sign-Up Java JSP Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting  Java JSP Application Hosting Resellers web hosting, website hosting, web site hosting Java JSP Application Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting
Java JSP Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python,JSP,  Fundraising
Java JSP Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting
WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

Java JSP Application Hosting Welcome Java JSP Application Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting Java JSP Application Hosting Fund Raising, Fundraising, web hosting Java JSP Application Hosting Resellers, web Hosting Java JSP Application Hosting Web Design, web Hosting Java JSP Application Hosting Extra Services,  web Hosting Java JSP Application Hosting Traffic Booster, web hosting Java JSP Application Hosting Traffic Booster, web hosting Java JSP Application Hosting Technical Support,  web Hosting Java JSP Application Hosting webmaster tips,  web Hosting Java JSP Application Hosting 30 Day Money Back, web hosting Java JSP Application Hosting Legal Notices for Web Hosting Java JSP Application Hosting Glossary Computer Terms for web Hosting Java JSP Application Hosting Contact Information - web hosting

Site Map
Java JSP Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python, JSP Java JSP Application Hosting Java JSP Application Hosting Java JSP Application Hosting Java JSP Application Hosting Java JSP Application Hosting How to Use the ButtonGroup Component (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)
Trail: Creating a GUI with JFC/Swing
Lesson: Using Swing Components
Section: How to Use Various Components
Home Page > Creating a GUI with JFC/Swing > Using Swing Components
How to Use the ButtonGroup Component

The ButtonGroup component manages the selected/unselected state for a set of buttons. For the group, the ButtonGroup instance guarantees that only one button can be selected at a time.

Initially, all buttons managed by a ButtonGroup instance are unselected.

How to Use ButtonGroup Features

You can use ButtonGroup with any set of objects that inherit from AbstractButton. Typically a button group contains instances of JRadioButton, JRadioButtonMenuItem, or JToggleButton. It would not make sense to put an instance of JButton or JMenuItem in a button group because JButton and JMenuItem do not implement the select/deselect button state.

In general, you will typically follow these steps to write code that uses a ButtonGroup component.
  1. Subclass JFrame
  2. Call ContextPane together with a layout manager
  3. Declare and configure a set of radio buttons or toggle buttons
  4. Instantiate a ButtonGroup object
  5. Call the add method on that buttongroup object in order to add each button to the group.

For details and a code example, see How to Use Radio Buttons. It shows how to use a ButtonGroup component to group a set of RadioButtons set into a JPanel.

The ButtonGroup API

 

Commonly Used Button Group Constructors/Methods
Constructor or Method Purpose
ButtonGroup() Create a ButtonGroup instance.
void add(AbstractButton)
void remove(AbstractButton)
Add a button to the group, or remove a button from the group.
public ButtonGroup getGroup()
(in DefaultButtonModel)
Get the ButtonGroup, if any, that controls a button. For example:
ButtonGroup group = ((DefaultButtonModel)button.getModel()).getGroup();
public ButtonGroup clearSelection() Clears the state of selected buttons in the ButtonGroup. None of the buttons in the ButtonGroup are selected .

ButtonGroup Examples

The following demonstration application uses the ButtonGroup component to group radio buttons displaying on a Window.

Example Where Described Notes
RadioButtonDemo How to Use Radio Buttons Uses radio buttons to determine which of five images it should display.
Previous page: How to Use Buttons, Check Boxes, and Radio Buttons
Next page: How to Use Color Choosers
 
 
 

Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . . .
.
.
. .
.
. .
. . . . . . . . . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting