Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


Class UIRadioGroup

public class UIRadioGroup extends UICheckGroup
{
  // Constructors
  public UIRadioGroup();
  public UIRadioGroup(String label);
  public UIRadioGroup(IUIComponent header);

  // Methods
  public IUIComponent add(IUIComponent comp, Object constraints,
        int index);
  public IUIComponent add(String name, Object constraints,
        int index);
  public boolean handleEvent(Event e);
}

This class implements a group box control for a list of UIRadioButton objects.

This class is very similar to the java.awt.CheckboxGroup class. The group box control contains a list of radio buttons, where only one radio button can be selected at a time.

Note The default layout manager for the UIRadioGroup class is the UIVerticalFlowLayout manager, so the constraints parameters of any methods that accept them are typically ignored.

A UIRadioGroup object can be created in several ways. The following example shows you how to create a radio group box and add UIRadioButton objects to it.

// Create an empty UIRadioGroup control
// and use the UIGroup.html.setName method inherited from
// UIGroup.htmlto set the label of the control.
UIRadioGroup uirg1 = new UIRadioGroup();
uirg1.setName("Options");

// Add buttons to the control with the add methods.
// You can add buttons in several different ways. Add the first
// button by supplying a String for the button's name.
uirg1.add("UIRadioButton1", null, 0);

// Add the second button by first creating a UIRadioButton,
// and then adding it with the add method.
UIRadioButton uirb = new UIRadioButton("UIRadioButton2");
uirg1.add(uirb, null, 1);

// Add the third button by supplying a component that can be
// used as the label for the UIRadioButton.
UIText uit = new UIText("UIRadioButton3", UIStatic.HOT);
uirg1.add(uit, null, 2);

The result is a group of three UIRadioButton objects contained in a UIRadioGroup control with an Options label.

Note The hot-track color is the same color as the button text color. As a result, hot-tracking does not appear to be functional.

UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UIPanel
        |
        +--UIGroup
          |
          +--UICheckGroup
            |
            +--UIRadioGroup

Constructors

UIRadioGroup

public UIRadioGroup();

Creates a UIRadioGroup control with no label.

Remarks:

Use the UIGroup.setName method to add a label.

UIRadioGroup

public UIRadioGroup(String label);

Creates a radio button group box control with the specified label.

ParameterDescription
label The label for the group control.

UIRadioGroup

public UIRadioGroup(IUIComponent header);

Creates a radio button group box control using the specified component as a label.

ParameterDescription
header A IUIComponent label for the group control.

Methods

add

public IUIComponent add(IUIComponent comp, Object constraints, int index);

Adds a UIRadioButton to the UIRadioGroup control, according to the specified constraints and index.

Return Value:

Returns the UIRadioButton that was added, if successful; otherwise, returns null.

ParameterDescription
comp A UIRadioButton, or a component to use for the name of the UIRadioButton that is added to the UIRadioGroup.
constraints The layout constraints, which depend on the current layout manager. If you are using the default layout manager, this parameter is ignored. For more information about possible values, see the layout manager's addLayoutComponent method.
index The zero-based index at which to insert the component.

Overrides:

add(IUIComponent,Object,int) in UICheckGroup.

add

public IUIComponent add(String name, Object constraints, int index);

Adds a UIRadioButton to the UIRadioGroup control, according to the specified constraints and index.

Return Value:

Returns the UIRadioButton that was added, if successful; otherwise, returns null.

ParameterDescription
name The name of the UIRadioButton that is added to the UIRadioGroup.
constraints The layout constraints, which depend on the current layout manager. If you are using the default layout manager, this parameter is ignored. For more information about possible values, see the layout manager's addLayoutComponent method.
index The zero-based index at which to insert the component.

Overrides:

add(String,Object,int) in UICheckGroup.

handleEvent

public boolean handleEvent(Event e);

Responds to events occurring within the control. This method ensures that only one radio button is selected at any one time.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
e The event that is posted.

Overrides:

handleEvent(Event) in UICheckGroup.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.