public class JLabelGroup extends JPanel
JLabelGroup is a JLabel set left to a Component. At RTL
systems, the label is set to the right.
Multiple JLabelGroup can be connected together. On the last instance of this
chain, rearrange() will be invoked, to rearrange all JLabels within
this chain to the same, maximum width. This will result into a nicely aligned layout.
JPanel.AccessibleJPanelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategylistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JLabelGroup(Component c,
JComponent label,
JLabelGroup pred)
Creates a new
JLabelGroup label with a given label JComponent. |
JLabelGroup(Component c,
String text)
Creates the first
JLabelGroup of a chain. |
JLabelGroup(Component c,
String text,
Icon icon,
JLabelGroup pred)
Creates a new
JLabelGroup label with an Icon. |
JLabelGroup(Component c,
String text,
JLabelGroup pred)
Creates a new
JLabelGroup element. |
| Modifier and Type | Method and Description |
|---|---|
protected static JComponent |
createDefaultLabel(String text,
Icon icon)
Creates the default
JComponent used as a label, if one of the text
constructors is used. |
JComponent |
getLabel()
Gets the
JComponent that is used as a label for this JLabelGroup. |
protected int |
getMaximumWidth()
Calculates the maximum label with of a
JLabelGroup chain. |
void |
rearrange()
Rearranges the
JLabelGroup chain. |
protected void |
setMinimumWidth(int width)
Recursively sets the minimum width of this JLabelGroup chain.
|
void |
setMnemonic(char key)
Sets a mnemonic key for this label.
|
void |
setMnemonic(int code)
Sets a mnemonic code for this label.
|
void |
setVerticalAlignment(int pos)
Sets the vertical alignment of the label, using
SwingConstants. |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, 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, 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, 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, updateadd, 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, validateTreeaction, 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, transferFocusUpCyclepublic JLabelGroup(Component c, String text)
JLabelGroup of a chain.c - Component to be labelledtext - Label textpublic JLabelGroup(Component c, String text, JLabelGroup pred)
JLabelGroup element.c - Component to be labelledtext - Label textpred - Predecessor JLabelGroup instance, or nullpublic JLabelGroup(Component c, String text, Icon icon, JLabelGroup pred)
JLabelGroup label with an Icon.c - Component to be labelledtext - Label texticon - Iconpred - Predecessor JLabelGroup instance, or nullpublic JLabelGroup(Component c, JComponent label, JLabelGroup pred)
JLabelGroup label with a given label JComponent. Use
this if you want to use a different label.c - Component to be labelledlabel - Label JComponentpred - Predecessor JLabelGroup instance, or nullprotected int getMaximumWidth()
JLabelGroup chain.
rearrange() will use this method to compute the width.public void setVerticalAlignment(int pos)
SwingConstants. Default is
SwingConstants.CENTER.pos - Alignment: TOP, CENTER or BOTTOM.protected void setMinimumWidth(int width)
rearrange().width - New minimum widthpublic void rearrange()
JLabelGroup chain. All labels in this chain are set to the
width of the broadest label. This method must be invoked on the last
JLabelGroup of a chain!
If further JLabelGroup objects are added later, this method must be invoked
again, on the new last element of the chain.
All JLabelGroup instances are regarded, even if they are currently
invisible.
public void setMnemonic(char key)
key - Key to be usedpublic void setMnemonic(int code)
code - Keycode to be usedpublic JComponent getLabel()
JComponent that is used as a label for this JLabelGroup.
Usually this is a JLabel, but you should not rely on this!JComponent used as a label.protected static JComponent createDefaultLabel(String text, Icon icon)
JComponent used as a label, if one of the text
constructors is used.text - Label texticon - Icon to be used, or nullJComponent showing the text and the iconCopyright © 2004–2016. All rights reserved.