Class ResizableTextLabel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
- Direct Known Subclasses:
GradientLabel
A text area in which the text can dynamically adjust its font size to fill
the whole area available.
- Version:
- $id$
- Author:
- Jernej Kamenik
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Helper class that notifies the resizable text label to resize its font when itself is being resized.Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty label.ResizableTextLabel
(String arg0) Creates a resizable text label with text.ResizableTextLabel
(String arg0, int arg1) Creates a resizable text label with text and predefined horizontal text aligment.ResizableTextLabel
(String text, Icon icon, int horizontalAlignment) Creates a resizable text label with text, icon and predefined horizontal text aligment and resizable font setting.ResizableTextLabel
(Icon image) Creates a resizable text label with an iconResizableTextLabel
(Icon image, int horizontalAlignment) Creates a resizable text label with icon and predefined horizontal text aligment and resizable font setting. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method was overriden to implement font resizing.int
Gets the number of character columns to be displayed.This method was overriden to implement font resizing.This method was overriden to implement font resizing.boolean
Returns the enhanced mode setting.boolean
Returns the resizable text font setting.protected void
This method hes been overriden to implement the feature of enhanced anti-aliasing paint of the label.protected void
resize()
Adjusts the size of the font to the size of the label.void
setColumns
(int newColumns) Sets the number of character columns to be displayed.void
setEnhanced
(boolean newEnhanced) Sets the enhanced mode setting.void
setMinimumSize
(Dimension newMinimumSize) This method was overriden to implement font resizing.void
setPreferredSize
(Dimension newPreferredSize) This method was overriden to implement font resizing.void
setResizable
(boolean newResizable) Sets the resizable text font setting.void
This method was overriden to implement font resizing.Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, getNextFocusableComponent, getPopupLocation, 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, setNextFocusableComponent, setOpaque, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
ResizableTextLabel
Creates a resizable text label with text, icon and predefined horizontal text aligment and resizable font setting.- Parameters:
text
- java.lang.String text to be displayed in the label.icon
- Icon image to be displayed in the label.horizontalAlignment
- int horizontal aligment of the text in the label.
-
ResizableTextLabel
Creates a resizable text label with text and predefined horizontal text aligment.- Parameters:
arg0
- java.lang.String text to be displayed in the label.arg1
- int horizontal aligment of the text in the label.
-
ResizableTextLabel
Creates a resizable text label with text.- Parameters:
arg0
- java.lang.String text to be displayed in the label.
-
ResizableTextLabel
Creates a resizable text label with icon and predefined horizontal text aligment and resizable font setting.- Parameters:
image
- Icon image to be displayed in the label.horizontalAlignment
- int horizontal aligment of the text in the label.
-
ResizableTextLabel
Creates a resizable text label with an icon- Parameters:
image
- Icon image to be displayed in the label.
-
ResizableTextLabel
public ResizableTextLabel()Creates an empty label.
-
-
Method Details
-
setColumns
public void setColumns(int newColumns) Sets the number of character columns to be displayed. This setting only has effect if resizable text font setting is enabled. Then the size of the font is adjusted to display the specified number of character columns.- Parameters:
newColumns
-
-
getColumns
public int getColumns()Gets the number of character columns to be displayed.- Returns:
- int
-
isResizable
public boolean isResizable()Returns the resizable text font setting.- Returns:
- boolean
-
setResizable
public void setResizable(boolean newResizable) Sets the resizable text font setting.- Parameters:
newResizable
-
-
setEnhanced
public void setEnhanced(boolean newEnhanced) Sets the enhanced mode setting. When true, the label is painted with anti-aliasing rendering hints.- Parameters:
newEnhanced
-
-
isEnhanced
public boolean isEnhanced()Returns the enhanced mode setting.- Returns:
- boolean
-
setText
This method was overriden to implement font resizing. -
resize
protected void resize()Adjusts the size of the font to the size of the label. -
addNotify
public void addNotify()This method was overriden to implement font resizing.- Overrides:
addNotify
in classJComponent
- See Also:
-
getPreferredSize
This method was overriden to implement font resizing.- Overrides:
getPreferredSize
in classJComponent
- Returns:
- Dimension preferred size of the label
- See Also:
-
setPreferredSize
This method was overriden to implement font resizing.- Overrides:
setPreferredSize
in classJComponent
- See Also:
-
getMinimumSize
This method was overriden to implement font resizing.- Overrides:
getMinimumSize
in classJComponent
- See Also:
-
setMinimumSize
This method was overriden to implement font resizing.- Overrides:
setMinimumSize
in classJComponent
- See Also:
-
paintComponent
This method hes been overriden to implement the feature of enhanced anti-aliasing paint of the label.- Overrides:
paintComponent
in classJComponent
- See Also:
-