com.limegroup.gnutella.gui
Class ButtonRow

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.limegroup.gnutella.gui.ButtonRow
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public final class ButtonRow
extends javax.swing.JPanel

This class generates a row of buttons with a standard spacing between them. The row of buttons can be oriented either horizontally or vertically, depending on the parameter.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int BOTTOM_GLUE
          This will create a "glue" at the bottom of the button panel, pushing the buttons to the top.
static int LEFT_GLUE
          This will create a "glue" at the left of the button panel, pushing the buttons to the left.
static int NO_GLUE
          This will give the button panel no glue, leaving the buttons in the middle.
static int RIGHT_GLUE
          This will create a "glue" at the right of the button panel, pushing the buttons to the right.
static int TOP_GLUE
          This will create a "glue" at the top of the button panel, pushing the buttons to the bottom.
static int X_AXIS
          Specifies that the buttons should be aligned along the x axis.
static int Y_AXIS
          Specifies that the buttons should be aligned along the y axis.
 
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
ButtonRow(java.lang.String[] labelKeys, java.lang.String[] toolTipKeys, java.awt.event.ActionListener[] listeners)
          Creates a row of buttons with standard separation between each button and with the specified tooltips and listeners.
ButtonRow(java.lang.String[] labelKeys, java.lang.String[] toolTipKeys, java.awt.event.ActionListener[] listeners, int orientation, int glue)
          Creates a row of buttons with standard separation between each button, aligned either vertically or horizontally, with or without glue.
 
Method Summary
 javax.swing.JButton getButtonAtIndex(int index)
          This method allows access to specific buttons in the button row.
 void setButtonEnabled(int buttonIndex, boolean enabled)
          Sets the button at the specified index to be enabled or disabled.
 void setButtonsEnabled(boolean enabled)
          Sets the enabled/disabled of all buttons in the row.
 void transformButton(int index, java.lang.String label, java.lang.String tip)
          Tranforms the text and the tooltip of the button.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

X_AXIS

public static final int X_AXIS
Specifies that the buttons should be aligned along the x axis.

See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
Specifies that the buttons should be aligned along the y axis.

See Also:
Constant Field Values

TOP_GLUE

public static final int TOP_GLUE
This will create a "glue" at the top of the button panel, pushing the buttons to the bottom.

See Also:
Constant Field Values

BOTTOM_GLUE

public static final int BOTTOM_GLUE
This will create a "glue" at the bottom of the button panel, pushing the buttons to the top.

See Also:
Constant Field Values

LEFT_GLUE

public static final int LEFT_GLUE
This will create a "glue" at the left of the button panel, pushing the buttons to the left.

See Also:
Constant Field Values

RIGHT_GLUE

public static final int RIGHT_GLUE
This will create a "glue" at the right of the button panel, pushing the buttons to the right.

See Also:
Constant Field Values

NO_GLUE

public static final int NO_GLUE
This will give the button panel no glue, leaving the buttons in the middle.

See Also:
Constant Field Values
Constructor Detail

ButtonRow

public ButtonRow(java.lang.String[] labelKeys,
                 java.lang.String[] toolTipKeys,
                 java.awt.event.ActionListener[] listeners)
Creates a row of buttons with standard separation between each button and with the specified tooltips and listeners. This constructor uses the default X_AXIS orientation and the default NO_GLUE.

Parameters:
labelKeys - the array of keys for looking up the locale-specific labels to use for the buttons
listeners - the array of ActionListeners to use for the buttons
Throws:
IllegalArgumentException - if the lengths of the arrays in the constructor are not all equal

ButtonRow

public ButtonRow(java.lang.String[] labelKeys,
                 java.lang.String[] toolTipKeys,
                 java.awt.event.ActionListener[] listeners,
                 int orientation,
                 int glue)
Creates a row of buttons with standard separation between each button, aligned either vertically or horizontally, with or without glue. The lengths of all arrays must be equal, or this will throw IllegalArgumentException.

Parameters:
labelKeys - the array of keys for looking up the locale-specific labels to use for the buttons
listeners - the array of ActionListeners to use for the buttons
orientation - the orientation to use for the row of buttons, either ButtonRow.X_AXIS or ButtonRow.Y_AXIS
glue - the glue determining the placement of the buttons, either TOP_GLUE, BOTTOM_GLUE, LEFT_GLUE, RIGHT_GLUE, or NO_GLUE
Throws:
IllegalArgumentException - if the lengths of the arrays in the constructor are not all equal
Method Detail

getButtonAtIndex

public javax.swing.JButton getButtonAtIndex(int index)
This method allows access to specific buttons in the button row.

Parameters:
index - the index of the button to retrieve
Returns:
the JButton at that index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is out of bounds

setButtonEnabled

public void setButtonEnabled(int buttonIndex,
                             boolean enabled)
Sets the button at the specified index to be enabled or disabled.

Parameters:
buttonIndex - the index of the button to enable or disable
enabled - whether to enable or disable the button

setButtonsEnabled

public void setButtonsEnabled(boolean enabled)
Sets the enabled/disabled of all buttons in the row.

Parameters:
enabled - the enabled/disabled state of the buttons

transformButton

public void transformButton(int index,
                            java.lang.String label,
                            java.lang.String tip)
Tranforms the text and the tooltip of the button.

Parameters:
index - The index of the button to change.
label - The new label for the button.
tip - The new tip for the button.