prefuse.util.ui
Class JToggleGroup

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by prefuse.util.ui.JToggleGroup
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class JToggleGroup
extends javax.swing.JPanel

Swing component representing a group of toggle buttons -- either checkboxes or radio buttons. This class uses a ListModel and ListSelectionModel to represent the selection state of the buttons.

Author:
jeffrey heer
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int CHECKBOX
           
protected  int m_axis
           
protected  javax.swing.ListModel m_data
           
protected  javax.swing.ButtonGroup m_group
           
protected  java.lang.String[] m_labels
           
protected  int m_margin
           
protected  javax.swing.ListSelectionModel m_sel
           
protected  int m_spacing
           
protected  int m_type
           
static int RADIO
           
 
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
JToggleGroup(int type, javax.swing.ListModel data)
          Create a new JToggleGroup.
JToggleGroup(int type, javax.swing.ListModel data, javax.swing.ListSelectionModel selection)
          Create a new JToggleGroup.
JToggleGroup(int type, java.lang.Object[] data)
          Create a new JToggleGroup.
 
Method Summary
 int getAxisType()
          Get the Box axis type used to orient the toggle group component.
 int getMargin()
          Get the margin, in pixels, used at the ends of the JToggleGroup.
 javax.swing.ListModel getModel()
          Get the ListModel backing this component.
 javax.swing.ListSelectionModel getSelectionModel()
          Get the ListSelectionModel used by this component.
 int getSpacing()
          Get the spacing between toggle group components.
protected  void initUI()
          Initialize the UI.
 void setAxisType(int axis)
          Set the Box axis type used to orient the toggle group component.
 void setBackground(java.awt.Color background)
          Set the background color of this toggle group.
 void setFont(java.awt.Font font)
          Set the font used by this toggle group.
 void setForeground(java.awt.Color foreground)
          Set the foreground color of this toggle group.
 void setGroupFocusable(boolean b)
          Sets if the various toggle buttons can receive the keyboard focus.
 void setLabels(java.lang.String[] labels)
          Set the labels to use for the Objects contained in the list model.
 void setMargin(int margin)
          Set the margin, in pixels, to use at the ends of the JToggleGroup.
 void setModel(javax.swing.ListModel model)
          Set the ListModel backing this component.
 void setSelectionModel(javax.swing.ListSelectionModel sel)
          Set the ListSelectionModel used by this component.
 void setSpacing(int spacing)
          Set the spacing between toggle group components.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CHECKBOX

public static final int CHECKBOX
See Also:
Constant Field Values

RADIO

public static final int RADIO
See Also:
Constant Field Values

m_type

protected final int m_type

m_margin

protected int m_margin

m_spacing

protected int m_spacing

m_axis

protected int m_axis

m_data

protected javax.swing.ListModel m_data

m_sel

protected javax.swing.ListSelectionModel m_sel

m_labels

protected java.lang.String[] m_labels

m_group

protected javax.swing.ButtonGroup m_group
Constructor Detail

JToggleGroup

public JToggleGroup(int type,
                    java.lang.Object[] data)
Create a new JToggleGroup.

Parameters:
type - the toggle button type to use, one of CHECKBOX or RADIO
data - the list data that should populate the toggle group

JToggleGroup

public JToggleGroup(int type,
                    javax.swing.ListModel data)
Create a new JToggleGroup.

Parameters:
type - the toggle button type to use, one of CHECKBOX or RADIO
data - the list model data backing the toggle group

JToggleGroup

public JToggleGroup(int type,
                    javax.swing.ListModel data,
                    javax.swing.ListSelectionModel selection)
Create a new JToggleGroup.

Parameters:
type - the toggle button type to use, one of CHECKBOX or RADIO
data - the list model data backing the toggle group
selection - the list selection model to use to monitor selection changes to the various toggle buttons.
Method Detail

initUI

protected void initUI()
Initialize the UI.


setAxisType

public void setAxisType(int axis)
Set the Box axis type used to orient the toggle group component.

Parameters:
axis - the axis type, one of BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS, or BoxLayout.PAGE_AXIS.

getAxisType

public int getAxisType()
Get the Box axis type used to orient the toggle group component.

Returns:
the axis type, one of BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS, or BoxLayout.PAGE_AXIS.

setMargin

public void setMargin(int margin)
Set the margin, in pixels, to use at the ends of the JToggleGroup.

Parameters:
margin - the margin in pixels

getMargin

public int getMargin()
Get the margin, in pixels, used at the ends of the JToggleGroup.

Returns:
the margin in pixels

setSpacing

public void setSpacing(int spacing)
Set the spacing between toggle group components.

Parameters:
spacing - the spacing, in pixels, to use between components

getSpacing

public int getSpacing()
Get the spacing between toggle group components.

Returns:
the spacing, in pixels, to use between components

setModel

public void setModel(javax.swing.ListModel model)
Set the ListModel backing this component.

Parameters:
model - the list model to use

getModel

public javax.swing.ListModel getModel()
Get the ListModel backing this component.

Returns:
the list model

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel sel)
Set the ListSelectionModel used by this component.

Parameters:
sel - the list selection model to use

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Get the ListSelectionModel used by this component.

Returns:
the list selection model to use

setLabels

public void setLabels(java.lang.String[] labels)
Set the labels to use for the Objects contained in the list model.

Parameters:
labels - the display labels to use in the interface component

setBackground

public void setBackground(java.awt.Color background)
Set the background color of this toggle group.

Overrides:
setBackground in class javax.swing.JComponent
See Also:
Component.setBackground(java.awt.Color)

setForeground

public void setForeground(java.awt.Color foreground)
Set the foreground color of this toggle group.

Overrides:
setForeground in class javax.swing.JComponent
See Also:
Component.setBackground(java.awt.Color)

setFont

public void setFont(java.awt.Font font)
Set the font used by this toggle group.

Overrides:
setFont in class javax.swing.JComponent
See Also:
Component.setFont(java.awt.Font)

setGroupFocusable

public void setGroupFocusable(boolean b)
Sets if the various toggle buttons can receive the keyboard focus.

Parameters:
b - true to set toggle buttons keyboard accessible, false to set them unaccessible.


Copyright © 2007 Regents of the University of California