CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.gui
Class MultilineLabel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by ch.randelshofer.gui.MultilineLabel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class MultilineLabel
extends java.awt.Canvas

Displays multiple lines of text.

Version:
1.0.2 2005-08-26 Call repaint after validating the parent to ensure that the label is drawn. Methods setBorderColor/getBorderColor added.
1.0.1 2004-11-01 Init variable "text" with an empty string.
1.0 2004-08-15 Created.
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
MultilineLabel()
          Creates new form.
 
Method Summary
 java.awt.Color getBorderColor()
           
 java.awt.Insets getInsets()
           
 java.awt.Dimension getPreferredSize()
           
 java.lang.String getText()
           
 void invalidate()
           
 void paint(java.awt.Graphics g)
           
 void select(int selectionStart, int selectionEnd)
          Selects the text between the specified start and end positions.
 void setBorderColor(java.awt.Color c)
           
 void setInsets(java.awt.Insets insets)
           
 void setMinRows(int rows)
           
 void setSelectionBackground(java.awt.Color c)
           
 void setText(java.lang.String text)
           
 int viewToModel(int x, int y)
          Converts the given place in the view coordinate system to the nearest representative location in the model.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, 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, getBaseline, getBaselineResizeBehavior, 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, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, setMaximumSize, setMinimumSize, setName, setPreferredSize, 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
 

Constructor Detail

MultilineLabel

public MultilineLabel()
Creates new form.

Method Detail

setSelectionBackground

public void setSelectionBackground(java.awt.Color c)

setBorderColor

public void setBorderColor(java.awt.Color c)

getBorderColor

public java.awt.Color getBorderColor()

viewToModel

public int viewToModel(int x,
                       int y)
Converts the given place in the view coordinate system to the nearest representative location in the model.


setText

public void setText(java.lang.String text)

getText

public java.lang.String getText()

select

public void select(int selectionStart,
                   int selectionEnd)
Selects the text between the specified start and end positions.

This method sets the start and end positions of the selected text, enforcing the restriction that the start position must be greater than or equal to zero. The end position must be greater than or equal to the start position, and less than or equal to the length of the text component's text. The character positions are indexed starting with zero. The length of the selection is endPosition - startPosition, so the character at endPosition is not selected. If the start and end positions of the selected text are equal, all text is deselected.

If the caller supplies values that are inconsistent or out of bounds, the method enforces these constraints silently, and without failure. Specifically, if the start position or end position is greater than the length of the text, it is reset to equal the text length. If the start position is less than zero, it is reset to zero, and if the end position is less than the start position, it is reset to the start position.

Parameters:
selectionStart - the zero-based index of the first character to be selected
selectionEnd - the zero-based end position of the text to be selected; the character at selectionEnd is not selected
See Also:
TextComponent.setSelectionStart(int), TextComponent.setSelectionEnd(int), TextComponent.selectAll()

invalidate

public void invalidate()
Overrides:
invalidate in class java.awt.Component

setInsets

public void setInsets(java.awt.Insets insets)

getInsets

public java.awt.Insets getInsets()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Component

setMinRows

public void setMinRows(int rows)

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Canvas

(c) Werner Randelshofer.
All rights reserved.