Class GradientLabel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
xal.extension.widgets.swing.wheelswitch.comp.GradientLabel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
- Direct Known Subclasses:
SimpleButton
A label that paints a gradient as a background. User can specify gradient
colors (one of them is the default label background) and direction (the
default is from the upper left to the upper right corner) relative to the
label's proportions.
- Version:
- $id$
- Author:
- Miha Kadunc
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
ResizableTextLabel.ResizableAdapter
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
ConstructorsConstructorDescriptionConstructs an empty GradientLabelGradientLabel
(String text) Constructs a GradientLabel with the specified text.GradientLabel
(String text, int horizontalAlignment) Constructor for GradientLabel.GradientLabel
(String text, Icon icon, int horizontalAlignment) Constructor for GradientLabel.GradientLabel
(Icon image) Constructs a GradientLabel with the specified icon.GradientLabel
(Icon image, int horizontalAlignment) Constructor for GradientLabel. -
Method Summary
Modifier and TypeMethodDescriptionReturns the backgroundStart, this is the color that is used for the start of label's gradient.boolean
Returns whether the gradient background is enabled.protected void
This method hes been overriden to implement the feature of enhanced anti-aliasing paint of the label.void
Sets the background color.void
setBackgroundStart
(Color newBackgroundStart) Sets the backgroundStart color.void
setGradientEnabled
(boolean gradientEnabled) Sets the gradientEnabled property.void
setGradientPoints
(double startX, double startY, double endX, double endY) Sets the start and end point of the label's gradient, relative to the label's size.Methods inherited from class xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
addNotify, getColumns, getMinimumSize, getPreferredSize, isEnhanced, isResizable, resize, setColumns, setEnhanced, setMinimumSize, setPreferredSize, setResizable, setText
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, 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
-
GradientLabel
public GradientLabel()Constructs an empty GradientLabel -
GradientLabel
Constructs a GradientLabel with the specified icon.- Parameters:
image
-
-
GradientLabel
Constructor for GradientLabel.- Parameters:
image
-horizontalAlignment
-
-
GradientLabel
Constructs a GradientLabel with the specified text.- Parameters:
text
-
-
GradientLabel
Constructor for GradientLabel.- Parameters:
text
-icon
-horizontalAlignment
-
-
GradientLabel
Constructor for GradientLabel.- Parameters:
text
-horizontalAlignment
-
-
-
Method Details
-
getBackgroundStart
Returns the backgroundStart, this is the color that is used for the start of label's gradient. The end color is that of the label's background.- Returns:
- Color
-
isGradientEnabled
public boolean isGradientEnabled()Returns whether the gradient background is enabled.- Returns:
- boolean
-
paintComponent
Description copied from class:ResizableTextLabel
This method hes been overriden to implement the feature of enhanced anti-aliasing paint of the label.- Overrides:
paintComponent
in classResizableTextLabel
- See Also:
-
setBackground
Sets the background color. This color is used for the gradient's end point.- Overrides:
setBackground
in classJComponent
- Parameters:
c
- The color to be set- See Also:
-
setBackgroundStart
Sets the backgroundStart color.- Parameters:
newBackgroundStart
- The backgroundStart to set- See Also:
-
setGradientEnabled
public void setGradientEnabled(boolean gradientEnabled) Sets the gradientEnabled property.- Parameters:
gradientEnabled
- The gradientEnabled to set- See Also:
-
setGradientPoints
public void setGradientPoints(double startX, double startY, double endX, double endY) Sets the start and end point of the label's gradient, relative to the label's size. Value 0 is the left/top edge of the label. 1 is the right/bottom edge of the label.- Parameters:
startX
- the x coordinate of the start of the gradientstartY
- the y coordinate of the start of the gradientendX
- the x coordinate of the end of the gradientendY
- the y coordinate of the end of the gradient
-