Class UIButtonBar
public class UIButtonBar extends Vector
{
// Fields
public final static int ABORTRETRYIGNORE;
public final static int BACKNEXTFINISHCANCEL;
public static int FLAT;
public final static int ID_ABORT;
public final static int ID_APPLY;
public final static int ID_BACK;
public final static int ID_CANCEL;
public final static int ID_FINISH;
public final static int ID_IGNORE;
public final static int ID_NEXT;
public final static int ID_NO;
public final static int ID_OK;
public final static int ID_RETRY;
public final static int ID_YES;
public final static int OK;
public final static int OKCANCEL;
public final static int OKCANCELAPPLY;
public static int RAISED;
public final static int RETRYCANCEL;
public final static int YESNO;
public final static int YESNOCANCEL;
// Constructors
public UIButtonBar();
public UIButtonBar(int buttonSet, int style);
public UIButtonBar(String buttons, int style);
public UIButtonBar(String buttons, String separator, int style);
// Methods
public void add(int id);
public void add(String text, int id);
public void add(String text);
public int addMany(String buttons, String separator,
int defaultButton);
public IUIComponent addTo(IUIContainer cont);
public IUIComponent getButton(String name);
public IUIComponent getButtonID(int id);
public int getDefaultIndex();
public Object getDefaultObject();
public int getIndex(IUIComponent find);
public static String loadButtonID(int id);
public void setDefault(Object object);
public void setDefault(int index);
public void setStyle(int i);
}
This class implements a container for a set of UIPushButton objects.
UIButtonBar objects are used extensively in classes, such as UIMessageBox, where a set of button choices needs to be grouped and displayed. The button labels are tokenized from the specified string buttons in the constructor. The separator character, or characters, may also be specified in the constructor (by default, the separator character is a comma).
The following example shows how to create and add a UIButtonBar to an UIMessageBox object.
// Create a UIButtonBar with two buttons labeled "Continue"
//and "Back".
// The button's style is FLAT.
UIButtonBar setupBtnbar = new UIButtonBar("Continue,Back",
FLAT);
// Set the "Continue" button as the default button on the bar
// with the setDefault method. The index of the button
// corresponds to the order in which the button was added.
setupBtnbar.setDefault(0);
// Use the add method to add another button to the bar.
// The label of the button is "Exit" and the style is FLAT
// by default.
setupBtnbar.add("Exit");
// Add the completed UIButtonBar to an UIMessageBox.
UIMessageBox SetUpStep = new UIMessageBox( parentFrame,
"MyApplication Setup", setupMessage,
UIMessageBox.INFORMATION, setupBtnbar);
Vector
|
+--UIButtonBar
public UIButtonBar();
Creates an empty button bar with a RAISED style. There are no button objects associated with the button bar; the default button index is initialized to -1.
public UIButtonBar(int buttonSet, int style);
Creates an button bar using default button configurations.
Parameter | Description |
buttonSet
| The set of buttons.
|
style
| The button style. This may be either FLAT or RAISED.
|
public UIButtonBar(String buttons, int style);
Creates a button bar using a comma-separated list of button labels.
Parameter | Description |
buttons
| A string that contains a list of button labels.
|
style
| The button's style. This may be either FLAT or RAISED.
|
public UIButtonBar(String buttons, String separator, int style);
Creates a button bar byusing a separated list of button labels. You can specify the separator or separators used to tokenize the button labels in the string.
Parameter | Description |
buttons
| A string that contains a list of button labels.
|
separator
| The character or characters that are used as separators between the button labels.
|
style
| The button's style. It may be either FLAT or RAISED.
|
public void add(int id);
Adds a new button to the list of buttons, using the current style.
Parameter | Description |
id
| The button's identifier. This may be any identifier, or one of the following predefined identifiers:
|
public void add(String text, int id);
Adds a new button to the list of buttons, using the current style.
The identifier does not need to be one of the predefined types. You can specify any identifier for the button (for example, add("I agree", 1234);).
Parameter | Description |
text
| The button's label.
|
id
| The button's identifier. This may be any identifier, or one of the following predefined identifiers:
|
public void add(String text);
Adds a new button to the list of buttons, using the current style.
Parameter | Description |
text
| The label of the button.
|
public int addMany(String buttons, String separator, int defaultButton);
Adds a list of buttons to the button bar, using the current style.
Return Value:
Returns the number of buttons that are added to the button bar.
Parameter | Description |
buttons
| A separated list of buttons.
|
separator
| The character or characters to use to tokenize the buttons list.
|
defaultButton
| The index of the default button.
|
public IUIComponent addTo(IUIContainer cont);
Adds the current group of buttons to a container.
Return Value:
Returns the default component; if no default was set, returns null.
Parameter | Description |
cont
| The container to add the buttons to.
|
Remarks:
The default button has a bold font when it is created. All other buttons have a non-bold font.
public IUIComponent getButton(String name);
Retrieves the component with the specified name.
Return Value:
Returns the button component; if the component is not found, returns null.
Parameter | Description |
name
| The name of the button to find in the list of buttons.
|
public IUIComponent getButtonID(int id);
Retrieves the component with the specified identifier.
Return Value:
Returns the button object, or null if the button is not found.
Parameter | Description |
id
| The button's identifier. This may be any identifier, or one of the following predefined identifiers:
|
public int getDefaultIndex();
Retrieves the index of the currently set default button for the button bar.
Return Value:
Returns the index for the default button.
public Object getDefaultObject();
Retrieves the object currently set as the default button for the button bar.
Return Value:
Returns the object that is the current default.
public int getIndex(IUIComponent find);
Retrieves the button index of the given component.
Return Value:
Returns the index of the button in the current the list of buttons, or -1 if the button not found.
Parameter | Description |
find
| The component to find in the list of buttons.
|
public static String loadButtonID(int id);
Used in the add(int id) method. This method can be used by any application to return a string for any of the identifiers.
Note The strings are localized to the user's platform.
Parameter | Description |
id
| The button's identifier. This may be any identifier, or one of the predefined identifiers.
|
public void setDefault(Object object);
Sets the default button on the button bar (the default button is the button that is pressed if you make no active selection).
Return Value:
No return value.
Parameter | Description |
object
| An object, which is the default button of the button bar.
|
public void setDefault(int index);
Sets the default button on the button bar (the default button is the button that is pressed if you make no active selection).
Return Value:
No return value.
Parameter | Description |
index
| The index of one of the button objects that is currently associated with the button bar.
|
public void setStyle(int i);
Sets the style of the button bar object.
Return Value:
No return value.
Parameter | Description |
i
| The style for the button bar may be either FLAT or RAISED.
|
- ABORTRETRYIGNORE
- A set of common buttons that consists of three button choices: Abort, Retry, and Ignore.
- BACKNEXTFINISHCANCEL
- A set of common buttons that consists of three button choices: Back, Next, Finish, and Cancel. This button set is typically used in Wizard dialog boxes.
- FLAT
- Specifies that the button is flat.
- ID_ABORT
- A string identifier associated with common Abort buttons.
- ID_APPLY
- A string identifier associated with common Apply buttons.
- ID_BACK
- A string identifier associated with common Back buttons.
- ID_CANCEL
- A string identifier associated with common Cancel buttons.
- ID_FINISH
- A string identifier associated with common Finish buttons.
- ID_IGNORE
- A string identifier associated with common ignore buttons.
- ID_NEXT
- A string identifier associated with common Next buttons.
- ID_NO
- A string identifier associated with common No buttons.
- ID_OK
- A string identifier associated with common OK buttons.
- ID_RETRY
- A string identifier associated with common Retry buttons.
- ID_YES
- A string identifier associated with common Yes buttons.
- OK
- A common button style, with only one button choice.
- OKCANCEL
- A set of common buttons that consists of two button choices: OK and Cancel.
- OKCANCELAPPLY
- A set of common buttons that consists of three button choices: OK, Cancel, and Apply. This button set is typically used in setup dialog boxes.
- RAISED
- Specifies that the button is raised.
- RETRYCANCEL
- A set of common buttons that consists of two button choices: Retry and Cancel.
- YESNO
- A set of common buttons that consists of two button choices: Yes and No.
- YESNOCANCEL
- A set of common buttons that consists of three button choices: Yes, No, and Cancel.