|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jdesktop.swingx.JXRadioGroup<T>
public class JXRadioGroup<T>
JXRadioGroup
is a group of radio buttons that functions as a unit. It
is similar in concept to a JComboBox
in functionality, but can offer
a better presentation for a small number of choices. JXRadioGroup
should be used in preference to JComboBox
when the number of choices
is small (less than six) or the choices are verbose.
Notes:
AbstractButton
, then the buttons will be added "as is" to the
container. If the generic type is anything else, buttons will be created as
JRadioButton
objects, and the button text will be set by calling
toString() on the value object.getChildButton(int)
or
getChildButton(Object)
and configure the buttons.
TODO back with a model (possibly reuse of extend ComboBoxModel
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JXRadioGroup()
Create a default JXRadioGroup with a default layout axis of BoxLayout.X_AXIS . |
|
JXRadioGroup(T[] radioValues)
Create a default JXRadioGroup with a default layout axis of BoxLayout.X_AXIS . |
Method Summary | ||
---|---|---|
void |
add(T radioValue)
You can use this method to manually add your own AbstractButton objects, provided you declared the class as JXRadioGroup<JRadioButton> . |
|
void |
addActionListener(ActionListener l)
Adds an ActionListener . |
|
static
|
create(T[] radioValues)
Convenience factory method. |
|
protected void |
fireActionEvent(ActionEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
|
ActionListener[] |
getActionListeners()
Returns an array of all the ActionListener s added
to this JRadioGroup with addActionListener(). |
|
AbstractButton |
getChildButton(int index)
Retrieve the child button by index. |
|
AbstractButton |
getChildButton(T value)
Retrieve the child button that represents this value. |
|
int |
getChildButtonCount()
Get the number of child buttons. |
|
AbstractButton |
getSelectedButton()
Gets the currently selected button. |
|
T |
getSelectedValue()
The currently selected value. |
|
void |
removeActionListener(ActionListener l)
Removes an ActionListener . |
|
void |
setEnabled(boolean enabled)
Enable/disable all of the child buttons |
|
void |
setLayoutAxis(int axis)
Set the layout axis of the radio group. |
|
void |
setSelectedValue(T value)
Selects the supplied value. |
|
void |
setValues(T[] radioValues)
Sets the values backing this group. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JXRadioGroup()
BoxLayout.X_AXIS
.
public JXRadioGroup(T[] radioValues)
BoxLayout.X_AXIS
.
radioValues
- the list of values used to create the group.Method Detail |
---|
public static <T> JXRadioGroup<T> create(T[] radioValues)
radioValues
- the list of values used to create the group.public void setLayoutAxis(int axis)
axis
- values from BoxLayout
.public void setValues(T[] radioValues)
radioValues
- the new backing values for this grouppublic void add(T radioValue)
JXRadioGroup<JRadioButton>
.
public AbstractButton getSelectedButton()
getSelectedValue()
public T getSelectedValue()
public void setSelectedValue(T value)
value
- the value to selectpublic AbstractButton getChildButton(int index)
public AbstractButton getChildButton(T value)
public int getChildButtonCount()
public void addActionListener(ActionListener l)
ActionListener
.
The ActionListener
will receive an ActionEvent
when a selection has been made.
l
- the ActionListener
that is to be notified#setSelectedItem
public void removeActionListener(ActionListener l)
ActionListener
.
l
- the ActionListener
to removepublic ActionListener[] getActionListeners()
ActionListener
s added
to this JRadioGroup with addActionListener().
ActionListener
s added or an empty
array if no listeners have been addedprotected void fireActionEvent(ActionEvent e)
e
- the event to pass to the listenersEventListenerList
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
enabled
- true if this component should be enabled, false otherwiseJComponent.setEnabled(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |