Class ReflectedImageLabel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JLabel
-
- org.pushingpixels.lafwidget.contrib.blogofbug.swing.components.ReflectedImageLabel
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
,RichComponent
public class ReflectedImageLabel extends JLabel implements RichComponent
A RichComponent which takes the supplied image, adds on 50% to the height of the image and draws a graduated alpha-blended reflection below the top aligned original image. The text (set by setRichText()) is drawn dynamically over the reflection, below the original image.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
Constructors Constructor Description ReflectedImageLabel(Image image, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.ReflectedImageLabel(Image image, String text)
Creates a new instance of a reflected label using the supplied image and textReflectedImageLabel(Image image, String text, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.ReflectedImageLabel(String imageURL)
See constructor for image label, this version of the constructor takes an image URL instead of the image object (the URL can be in string format).ReflectedImageLabel(String imageURL, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.ReflectedImageLabel(String imageURL, String text, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Dimension
getPreferredSize()
Overrides the default getPreferedSize() which has been controlled by the created image and adds 50% onto the height to allow for the reflection.String
getRichText()
See interface definitionvoid
paintComponent(Graphics graphics)
Paints the componentvoid
prePaintImage()
See interface definitionvoid
setAlpha(float alphaLevel)
Sets the transparency of the componentvoid
setImage(Image image)
Deprecated.Please use setRichImage() instead from the RichComponent interfacevoid
setLabel(String text)
Deprecated.Use setRichText() insteadvoid
setRichImage(Image image)
See interface definitionvoid
setRichImage(File image)
See interface definitionvoid
setRichImage(URL image)
Assigns an image to the component, the width and height taken from the supplied imagevoid
setRichText(String text)
See interface definitionprotected void
setupImage(Image image)
Adds a reflection to the supplied image-
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, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
-
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, getMaximumSize, getMinimumSize, 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, 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, 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 Detail
-
ReflectedImageLabel
public ReflectedImageLabel(Image image, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.Creates a new instance from the supplied image object- Parameters:
image
- The Image objectwidth
- The prefered width of the image when rendered by a rich containerheight
- The prefered heightof the image when rendered by a rich container
-
ReflectedImageLabel
public ReflectedImageLabel(Image image, String text, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.Creates a new instance of a reflected label for the supplied image, also setting the text to be associated with the image.- Parameters:
image
- The imagetext
- The text labelwidth
- The prefered width of the image when rendered by a rich containerheight
- The prefered height of the image when rendered by a rich container
-
ReflectedImageLabel
public ReflectedImageLabel(Image image, String text)
Creates a new instance of a reflected label using the supplied image and text- Parameters:
image
- The image to be usedtext
- The text to be displayed
-
ReflectedImageLabel
public ReflectedImageLabel(String imageURL)
See constructor for image label, this version of the constructor takes an image URL instead of the image object (the URL can be in string format).- Parameters:
imageURL
- A URL (in string form) of the image.
-
ReflectedImageLabel
public ReflectedImageLabel(String imageURL, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.Creates a new instance, setting the width and the height that may be used by the RichContainer- Parameters:
imageURL
- The URL of the image (String form)width
- The prefered width of the image when rendered by a rich containerheight
- The prefered height of the image when rendered by a rich container
-
ReflectedImageLabel
public ReflectedImageLabel(String imageURL, String text, int width, int height)
Deprecated.This function will be removed, use setNeutralWidth() on JCarousel instead.Creates a new instance, using the image specified in the URL string, the prefered dimensions and sets the Rich text as well- Parameters:
imageURL
- The URL of the image in text formtext
- The RichText to be displayedwidth
- The prefered width of the image when rendered by a rich containerheight
- The prefered height of the image when rendered by a rich container
-
-
Method Detail
-
setLabel
public void setLabel(String text)
Deprecated.Use setRichText() insteadDepricated.- Parameters:
text
- The rich text
-
setupImage
protected void setupImage(Image image)
Adds a reflection to the supplied image- Parameters:
image
- The image object to use to pre-render the reflection
-
setAlpha
public void setAlpha(float alphaLevel)
Sets the transparency of the component- Specified by:
setAlpha
in interfaceRichComponent
- Parameters:
alphaLevel
- The alpha level of the object- See Also:
RichComponent
-
setImage
public void setImage(Image image)
Deprecated.Please use setRichImage() instead from the RichComponent interfaceDeprecated- Parameters:
image
- An image object to use (reflection will be added)- See Also:
RichComponent
-
getPreferredSize
public Dimension getPreferredSize()
Overrides the default getPreferedSize() which has been controlled by the created image and adds 50% onto the height to allow for the reflection.- Overrides:
getPreferredSize
in classJComponent
- Returns:
- The prefered dimensions of the component
-
paintComponent
public void paintComponent(Graphics graphics)
Paints the component- Overrides:
paintComponent
in classJComponent
- Parameters:
graphics
- The graphics context
-
setRichImage
public void setRichImage(URL image)
Assigns an image to the component, the width and height taken from the supplied image- Specified by:
setRichImage
in interfaceRichComponent
- Parameters:
image
- The URL of the image
-
setRichImage
public void setRichImage(File image)
See interface definition- Specified by:
setRichImage
in interfaceRichComponent
- Parameters:
image
- See interface definition- See Also:
RichComponent
-
setRichImage
public void setRichImage(Image image)
See interface definition- Specified by:
setRichImage
in interfaceRichComponent
- Parameters:
image
- See interface definition- See Also:
RichComponent
-
prePaintImage
public void prePaintImage()
See interface definition- Specified by:
prePaintImage
in interfaceRichComponent
- See Also:
RichComponent
-
setRichText
public void setRichText(String text)
See interface definition- Specified by:
setRichText
in interfaceRichComponent
- Parameters:
text
- See interface definition- See Also:
RichComponent
-
getRichText
public String getRichText()
See interface definition- Specified by:
getRichText
in interfaceRichComponent
- Returns:
- See interface definition
- See Also:
RichComponent
-
-