net.jbeans.ui.label
Class OrientedLabel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JLabel
                  extended bynet.jbeans.ui.label.OrientedLabel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants

public class OrientedLabel
extends javax.swing.JLabel
implements java.io.Serializable

OrientedLabel is a display area for a short text string or an image, or both. A label does not react to input events. As a result, it cannot get the keyboard focus. You can specify the orientation of OrientedLabel object.

Version:
$Revision: 1.1.1.1 $
Author:
Masahiro Takatsuka (masa@jbeans.net)
See Also:
JLabel, Serializable, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JLabel
javax.swing.JLabel.AccessibleJLabel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JLabel
labelFor
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OrientedLabel()
          Creates an OrientedLabel instance with no image and with an empty string for the title.
OrientedLabel(javax.swing.Icon image)
          Creates an OrientedLabel instance with the specified image.
OrientedLabel(javax.swing.Icon image, int horizontalAlignment)
          Creates an OrientedLabel instance with the specified image and horizontal alignment.
OrientedLabel(java.lang.String text)
          Creates an OrientedLabel instance with the specified text.
OrientedLabel(java.lang.String text, javax.swing.Icon image, int horizontalAlignment)
           
OrientedLabel(java.lang.String text, int horizontalAlignment)
          Creates an OrientedLabel instance with the specified text and horizontal alignment.
 
Method Summary
 double getAngle()
          Gets a rotation angle.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this container.
 void paint(java.awt.Graphics g)
          paints Label object.
 void setAngle(double angle)
          Sets a rotation angle.
 void setDisabledIcon(javax.swing.Icon disabledIcon)
          Set the icon to be displayed if this JLabel is "disabled" (JLabel.setEnabled(false)).
 void setDisplayedMnemonic(char aChar)
          Specifies the displayedMnemonic as a char value.
 void setDisplayedMnemonic(int key)
          Specify a keycode that indicates a mnemonic key.
 void setHorizontalAlignment(int alignment)
          Sets the alignment of the label's contents along the X axis.
 void setHorizontalTextPosition(int textPosition)
          Sets the horizontal position of the label's text, relative to its image.
 void setIcon(javax.swing.Icon icon)
          Defines the icon this component will display.
 void setIconTextGap(int iconTextGap)
          If both the icon and text properties are set, this property defines the space between them.
 void setLabelFor(java.awt.Component c)
          Set the component this is labelling.
 void setText(java.lang.String text)
          Defines the single line of text this component will display.
 void setUI(javax.swing.plaf.LabelUI ui)
          Sets the L&F object that renders this component.
 void setVerticalAlignment(int alignment)
          Sets the alignment of the label's contents along the Y axis.
 void setVerticalTextPosition(int textPosition)
          Sets the vertical position of the label's text, relative to its 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, setDisplayedMnemonicIndex, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrientedLabel

public OrientedLabel()
Creates an OrientedLabel instance with no image and with an empty string for the title. The label is centered vertically in its display area. The label's contents, once set, will be displayed on the leading edge of the label's display area.


OrientedLabel

public OrientedLabel(javax.swing.Icon image)
Creates an OrientedLabel instance with the specified image. The label is centered vertically and horizontally in its display area.


OrientedLabel

public OrientedLabel(javax.swing.Icon image,
                     int horizontalAlignment)
Creates an OrientedLabel instance with the specified image and horizontal alignment. The label is centered vertically in its display area.

Parameters:
horizontalAlignment - One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.

OrientedLabel

public OrientedLabel(java.lang.String text)
Creates an OrientedLabel instance with the specified text. The label is aligned against the leading edge of its display area, and centered vertically.

Parameters:
text - The text to be displayed by the label.

OrientedLabel

public OrientedLabel(java.lang.String text,
                     javax.swing.Icon image,
                     int horizontalAlignment)

OrientedLabel

public OrientedLabel(java.lang.String text,
                     int horizontalAlignment)
Creates an OrientedLabel instance with the specified text and horizontal alignment. The label is centered vertically in its display area.

Parameters:
text - The text to be displayed by the label.
horizontalAlignment - One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.
Method Detail

setAngle

public void setAngle(double angle)
Sets a rotation angle.

Parameters:
angle - the rotation angle in radian.

getAngle

public double getAngle()
Gets a rotation angle.

Returns:
a rotation angle in radian.

paint

public void paint(java.awt.Graphics g)
paints Label object.


getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this container.


getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size.


setUI

public void setUI(javax.swing.plaf.LabelUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - the LabelUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

setText

public void setText(java.lang.String text)
Defines the single line of text this component will display. If the value of text is null or empty string, nothing is displayed.

The default value of this property is null.

This is a JavaBeans bound property.

See Also:
setVerticalTextPosition(int), setHorizontalTextPosition(int), setIcon(javax.swing.Icon)

setIcon

public void setIcon(javax.swing.Icon icon)
Defines the icon this component will display. If the value of icon is null, nothing is displayed.

The default value of this property is null.

This is a JavaBeans bound property.

See Also:
setVerticalTextPosition(int), setHorizontalTextPosition(int), JLabel.getIcon()

setDisabledIcon

public void setDisabledIcon(javax.swing.Icon disabledIcon)
Set the icon to be displayed if this JLabel is "disabled" (JLabel.setEnabled(false)).

The default value of this property is null.

Parameters:
disabledIcon - the Icon to display when the component is disabled
See Also:
JLabel.getDisabledIcon(), JComponent.setEnabled(boolean)

setDisplayedMnemonic

public void setDisplayedMnemonic(int key)
Specify a keycode that indicates a mnemonic key. This property is used when the label is part of a larger component. If the labelFor property of the label is not null, the label will call the requestFocus method of the component specified by the labelFor property when the mnemonic is activated.

See Also:
JLabel.getLabelFor(), setLabelFor(java.awt.Component)

setDisplayedMnemonic

public void setDisplayedMnemonic(char aChar)
Specifies the displayedMnemonic as a char value.

Parameters:
aChar - a char specifying the mnemonic to display
See Also:
setDisplayedMnemonic(int)

setIconTextGap

public void setIconTextGap(int iconTextGap)
If both the icon and text properties are set, this property defines the space between them.

The default value of this property is 4 pixels.

This is a JavaBeans bound property.

See Also:
JLabel.getIconTextGap()

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Sets the alignment of the label's contents along the Y axis.

The default value of this property is CENTER.

Parameters:
alignment - One of the following constants defined in SwingConstants: TOP, CENTER (the default), or BOTTOM.
See Also:
SwingConstants, JLabel.getVerticalAlignment()

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Sets the alignment of the label's contents along the X axis.

This is a JavaBeans bound property.

Parameters:
alignment - One of the following constants defined in SwingConstants: LEFT, CENTER (the default for image-only labels), RIGHT, LEADING (the default for text-only labels) or TRAILING.
See Also:
SwingConstants, JLabel.getHorizontalAlignment()

setVerticalTextPosition

public void setVerticalTextPosition(int textPosition)
Sets the vertical position of the label's text, relative to its image.

The default value of this property is CENTER.

This is a JavaBeans bound property.

Parameters:
textPosition - One of the following constants defined in SwingConstants: TOP, CENTER (the default), or BOTTOM.
See Also:
SwingConstants, JLabel.getVerticalTextPosition()

setHorizontalTextPosition

public void setHorizontalTextPosition(int textPosition)
Sets the horizontal position of the label's text, relative to its image.

Throws:
java.lang.IllegalArgumentException
See Also:
SwingConstants

setLabelFor

public void setLabelFor(java.awt.Component c)
Set the component this is labelling. Can be null if this does not label a Component. If the displayedMnemonic property is set and the labelFor property is also set, the label will call the requestFocus method of the component specified by the labelFor property when the mnemonic is activated.

Parameters:
c - the Component this label is for, or null if the label is not the label for a component
See Also:
JLabel.getDisplayedMnemonic(), setDisplayedMnemonic(int)


Copyright © 2003 JBean project. All Rights Reserved.