com.symantec.itools.javax.swing
Class JButtonGroupPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.symantec.itools.javax.swing.JButtonGroupPanel

public class JButtonGroupPanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener

A rectangular panel that contains a ButtonGroup and supports various selection actions.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  java.util.Vector buttons
          The contained buttons.
protected  javax.swing.ButtonGroup group
          The ButtonGroup the buttons contained by this panel belong to.
protected  java.util.Vector listeners
          Button listeners.
 
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
 
Constructor Summary
JButtonGroupPanel()
          Constructs a default JButtonGroupPanel object.
JButtonGroupPanel(javax.swing.ButtonGroup grp)
          Constructs a JButtonGroupPanel for the given ButtonGroup.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Implements the ActionListener interface.
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified listener.
protected  void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
          Standard routine to implement the various "add to container" methods.
 java.util.Enumeration getElements()
          Gets the buttons in this panel's ButtonGroup.
 javax.swing.AbstractButton getSelection()
          Gets the currently selected button.
 boolean isSelected(javax.swing.AbstractButton btn)
          Determines whether the specified button is selected.
 boolean isSelected(java.lang.String text)
          Determines whether button with the specified text is selected.
 void remove(javax.swing.AbstractButton btn)
          Removes an AbstractButton from this panel.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified listener.
 void setSelection(javax.swing.AbstractButton btn, boolean f)
          Determines whether the specified button is selected.
 void setSelection(java.lang.String text, boolean f)
          Determines whether the button with the specified text is selected.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buttons

protected java.util.Vector buttons
The contained buttons. All are of type AbstractButton.

listeners

protected java.util.Vector listeners
Button listeners. All are of type ActionListener.
See Also:
addActionListener(java.awt.event.ActionListener), removeActionListener(java.awt.event.ActionListener)

group

protected javax.swing.ButtonGroup group
The ButtonGroup the buttons contained by this panel belong to. By default, a new ButtonGroup is created for the buttons added to this panel.
Constructor Detail

JButtonGroupPanel

public JButtonGroupPanel()
Constructs a default JButtonGroupPanel object.

JButtonGroupPanel

public JButtonGroupPanel(javax.swing.ButtonGroup grp)
Constructs a JButtonGroupPanel for the given ButtonGroup. All buttons in the group are automatically added to the panel.
Parameters:
grp - the ButtonGroup this panel is for
Method Detail

getElements

public java.util.Enumeration getElements()
Gets the buttons in this panel's ButtonGroup.

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified listener.
Parameters:
listener - the listener to add
See Also:
removeActionListener(java.awt.event.ActionListener)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified listener.
Parameters:
listener - the listener to remove
See Also:
addActionListener(java.awt.event.ActionListener)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Implements the ActionListener interface.

Sends the given ActionEvent to all of the listeners registered using addActionListener.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

addImpl

protected void addImpl(java.awt.Component comp,
                       java.lang.Object constraints,
                       int index)
Standard routine to implement the various "add to container" methods.
Adds an AbstractButton to this panel if it hasn't already been added. It is also added to this panel's ButtonGroup.
Overrides:
addImpl in class java.awt.Container

remove

public void remove(javax.swing.AbstractButton btn)
Removes an AbstractButton from this panel. It is also removed from this panel's ButtonGroup.
Parameters:
btn - the button to remove

setSelection

public void setSelection(javax.swing.AbstractButton btn,
                         boolean f)
Determines whether the specified button is selected. Selecting a button automatically ensures that all the other buttons are de-selected.
Parameters:
btn - the button
f - true to select the button, false to de-select it

setSelection

public void setSelection(java.lang.String text,
                         boolean f)
Determines whether the button with the specified text is selected. Selecting a button automatically ensures that all the other buttons are de-selected.
Parameters:
text - the text of the desired button
f - true to select the button, false to de-select it

getSelection

public javax.swing.AbstractButton getSelection()
Gets the currently selected button.
Returns:
the selected button, or null if none is selected

isSelected

public boolean isSelected(javax.swing.AbstractButton btn)
Determines whether the specified button is selected.
Parameters:
btn - the button to check
Returns:
true if the button is selected, false otherwise

isSelected

public boolean isSelected(java.lang.String text)
Determines whether button with the specified text is selected.
Parameters:
text - the text of the button to check
Returns:
true if the button is selected, false otherwise