public class ButtonPanel extends KPanel
KPanel
that arranges
buttons in a row, in such a way that the buttons are all of equal size,
and justified flush with the right or left edge of the panel. Many Kiwi
dialogs and frames provide buttons in their lower-right areas or toolbars
in their upper-left areas that are positioned in just this way; this
class eliminates the need to perform the layout explicitly in code each
time this effect is desired.
The row of buttons is anchored at either the left or the right edge of the panel. If the sum of the preferred widths of the buttons exceeds the available horizontal space, the buttons are compressed horizontally to fit.
KPanel
,
Serialized FormModifier and Type | Class and Description |
---|---|
private class |
ButtonPanel.AnchorLayout |
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SPACING
The default horizontal spacing.
|
private static int |
LEFT |
private KPanel |
p_buttons |
private static int |
RIGHT |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
ButtonPanel()
Construct a new
ButtonPanel with the default horizontal
spacing and right alignment. |
ButtonPanel(int alignment)
Construct a new
ButtonPanel with default horizontal
spacing and the given alignment. |
ButtonPanel(int alignment,
int spacing)
Construct a new
ButtonPanel with the given horizontal
spacing and alignment. |
Modifier and Type | Method and Description |
---|---|
void |
addButton(AbstractButton button)
Add a button to the
ButtonPanel . |
void |
addButton(AbstractButton button,
int pos)
Add a button to the
ButtonPanel at the specified position. |
AbstractButton |
getButton(int pos)
Get a reference to the button at the specified position in the
ButtonPanel . |
int |
getButtonCount()
Get the number of buttons in this
ButtonPanel . |
void |
removeButton(AbstractButton button)
Remove a button from the
ButtonPanel . |
void |
removeButton(int pos)
Remove a button from the specified position in the
ButtonPanel . |
getComponentByName, paintComponent, setFocusOrder, setTexture
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
private static final int LEFT
private static final int RIGHT
public static final int DEFAULT_SPACING
public ButtonPanel()
ButtonPanel
with the default horizontal
spacing and right alignment.public ButtonPanel(int alignment)
ButtonPanel
with default horizontal
spacing and the given alignment.alignment
- The alignment of the buttons within their containing
panel; one of SwingConstants.LEFT
or
SwingConstants.RIGHT
.public ButtonPanel(int alignment, int spacing)
ButtonPanel
with the given horizontal
spacing and alignment.spacing
- The size of the gap (in pixels) to place between buttons
horizontally.alignment
- The alignment of the buttons within their containing
panel; one of SwingConstants.LEFT
or
SwingConstants.RIGHT
.public void addButton(AbstractButton button)
ButtonPanel
.button
- The button to add.removeButton(javax.swing.AbstractButton)
public void addButton(AbstractButton button, int pos) throws IllegalArgumentException
ButtonPanel
at the specified position.button
- The button to add.pos
- The position at which to add the button. The value 0 denotes
the first position, and -1 denotes the last position.IllegalArgumentException
- If the value of
pos
is invalid.public AbstractButton getButton(int pos)
ButtonPanel
.pos
- The position of the button to retrieve.public void removeButton(AbstractButton button)
ButtonPanel
.button
- The button to remove.addButton(javax.swing.AbstractButton)
public void removeButton(int pos)
ButtonPanel
.pos
- The position of the button to remove, where 0 denotes the
first position.public int getButtonCount()
ButtonPanel
.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses