Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.awt.field
Class WrappingLabel  view WrappingLabel download WrappingLabel.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended bycom.flexstor.common.awt.field.WrappingLabel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class WrappingLabel
extends java.awt.Canvas

This class displays lines of text and wraps them around. To work properly, one dimension (width or height) must be set with setPreferredWidth/Height methods. The other dimension will be calculated.


Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int align
           
static int ALIGN_CENTERED
           
static int ALIGN_LEFT
           
static int ALIGN_RIGHT
           
protected  int baseline
           
protected  java.awt.Dimension dimPreferred
           
protected  java.awt.FontMetrics fm
           
protected  java.lang.String text
           
 
Fields inherited from class java.awt.Canvas
 
Fields inherited from class java.awt.Component
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
 
Constructor Summary
WrappingLabel()
           
 
Method Summary
protected  int calculatePreferredHeight(int nWidth)
          Calculates height for a given width.
protected  int calculatePreferredWidth(int nHeight)
          Calculates width for a given height.
 java.awt.Dimension getMinimumSize()
          Returns the component's minimum size.
 java.awt.Dimension getPreferredSize()
          This method returns reasonable values after addNotify has been called.
 void setAlignStyle(int newAlignStyle)
           
 void setPreferredHeight(int height)
          Sets the preferred height.
 void setPreferredWidth(int width)
          Sets the preferred width.
 void setText(java.lang.String newText)
           
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dimPreferred

protected java.awt.Dimension dimPreferred

text

protected java.lang.String text

align

protected int align

baseline

protected int baseline

fm

protected transient java.awt.FontMetrics fm

ALIGN_LEFT

public static final int ALIGN_LEFT
See Also:
Constant Field Values

ALIGN_CENTERED

public static final int ALIGN_CENTERED
See Also:
Constant Field Values

ALIGN_RIGHT

public static final int ALIGN_RIGHT
See Also:
Constant Field Values
Constructor Detail

WrappingLabel

public WrappingLabel()
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
This method returns reasonable values after addNotify has been called. This works fine when a layout manager is used, otherwise the method should be called AFTER the peer is realized.


getMinimumSize

public java.awt.Dimension getMinimumSize()
Description copied from class: java.awt.Component
Returns the component's minimum size.


setPreferredWidth

public void setPreferredWidth(int width)
Sets the preferred width. The height will be calculated.


setPreferredHeight

public void setPreferredHeight(int height)
Sets the preferred height. The width will be calculated.


calculatePreferredWidth

protected int calculatePreferredWidth(int nHeight)
Calculates width for a given height. This only works approximate because stringWidth does not consider line breaks etc. For now, there is no need to improve this method.


calculatePreferredHeight

protected int calculatePreferredHeight(int nWidth)
Calculates height for a given width. (modified code from Symantec's paint method)


setText

public void setText(java.lang.String newText)

setAlignStyle

public void setAlignStyle(int newAlignStyle)