com.jidesoft.swing
Class ClickThroughStyledLabel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
com.jidesoft.swing.StyledLabel
com.jidesoft.swing.ClickThroughStyledLabel
- All Implemented Interfaces:
- MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, MouseInputListener, SwingConstants
public class ClickThroughStyledLabel
- extends StyledLabel
- implements MouseInputListener
ClickThroughStyledLabel is a special ClickThroughStyledLabel that will retarget all mouse events to
specified target component.
For example, you need to paint some text on a JComponent. Usually you can call Java2D paint text method and paint the
text. However the other way to do it is to add JLabel to JComponent and JLabel will not only paint the text but also
an optional icon which is better. However if you had mouse listener added to JComponent, the mouse listener will not
receive any mouse events when mouse clicks on the JLabel. By using this ClickThroughLabel, mouse event will
be passed to underlying JComponent.
Please note, we didn't pass all mouse events. In most cases, MOUSE_EXITED and MOUSE_ENTERED doesn't make sense to
pass through. However there are cases, for example when the JLabel is at the border of JComponent, you may expect
MOUSE_ENTERED event on JComponent but it will not happen. So please be aware of those cases so that you don't depend
on it for important decision in your code.
- See Also:
- Serialized Form
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 |
Methods inherited from class com.jidesoft.swing.StyledLabel |
addStyleRange, addStyleRanges, clearStyleRange, clearStyleRanges, getMaximumSize, getMaxRows, getMinimumSize, getMinRows, getPreferredWidth, getRowGap, getRows, getStyleRanges, getUIClassID, isIgnoreColorSettings, isLineWrap, isTruncated, setIgnoreColorSettings, setLineWrap, setMaxRows, setMinRows, setPreferredWidth, setRowGap, setRows, setStyleRanges, setTruncated, updateUI |
Methods inherited from class javax.swing.JLabel |
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition |
Methods inherited from class javax.swing.JComponent |
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, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, 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, 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, hide, 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, transferFocusUpCycle |
ClickThroughStyledLabel
public ClickThroughStyledLabel()
ClickThroughStyledLabel
public ClickThroughStyledLabel(Icon image)
ClickThroughStyledLabel
public ClickThroughStyledLabel(Icon image,
int horizontalAlignment)
ClickThroughStyledLabel
public ClickThroughStyledLabel(String text)
ClickThroughStyledLabel
public ClickThroughStyledLabel(String text,
int horizontalAlignment)
ClickThroughStyledLabel
public ClickThroughStyledLabel(String text,
Icon icon,
int horizontalAlignment)
getTarget
public Component getTarget()
setTarget
public void setTarget(Component target)
installListeners
protected void installListeners()
uninstallListeners
protected void uninstallListeners()
mouseClicked
public void mouseClicked(MouseEvent e)
- Specified by:
mouseClicked
in interface MouseListener
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressed
in interface MouseListener
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleased
in interface MouseListener
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEntered
in interface MouseListener
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExited
in interface MouseListener
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDragged
in interface MouseMotionListener
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMoved
in interface MouseMotionListener