jv.objectGui
Class PsMultiLineLabel
- java.lang.Object
-
- java.awt.Component
-
- jv.objectGui.PsMultiLineLabel
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
public class PsMultiLineLabel extends java.awt.ComponentA label that may contain multiple lines. Lines are automatically wrapped at the end of the label. UseLabel.CENTER, Label.LEFT, Label.RIGHTto specify the horizontal alignment of the text.After changing the text or alignment of this component, validate() must be called to enforce a new layout.
- See Also:
PuString.splitString(String, int, FontMetrics), Serialized Form- Author:
- Eike Preuss
- Version:
- 11.08.03, 2.10 revised (kp) Now a lightweight component, superclass changed to Component from Canvas.
21.07.03, 2.00 revised (kp) Methods update() removed, and enforce calling of validate().
21.07.03, 1.50 revised (kp) Deprecated method preferredSize() removed.
28.01.03, 1.40 revised (ep) Removed overrides of setSize etc. and implemented 'validate' instead (infinite loop bug).
14.11.02, 1.30 revised (ep) Make sure that after setBounds etc is called there is still a revalidation at next paint.
Reason for this is: If setBounds is called from LayoutManager the whole validation gets weird.
12.06.02, 1.20 revised (ep) Split the text whenever the size of the component is set (so preferredSize is up to date).
11.03.02, 1.10 revised (ep) Revalidate layout when text/alignment is changed.
18.01.02, 1.00 created (ep)
-
-
Field Summary
-
Constructor Summary
Constructors Constructor and Description PsMultiLineLabel()Create label with empty text and left alignment.PsMultiLineLabel(java.lang.String text)Create label with given text in multiple lines, and left alignment.PsMultiLineLabel(java.lang.String text, int align)Create label with given text in multiple lines and given alignment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intgetAlignment()Get alignment of label.java.awt.DimensiongetPreferredSize()Get preferred layout size of this component.java.lang.StringgetText()Get text on this multi line label.java.awt.ColorgetTextColor()Get color of text, if null then default color of component is used.voidpaint(java.awt.Graphics g)Draw split string if splitting was successful, otherwise just return without any drawing.voidsetAlignment(int align)Same as injava.awt.Label.voidsetText(java.lang.String text)Set text on this multi line label.voidsetTextColor(java.awt.Color color)Set color of text, if null then default color of component is used.voidvalidate()Enforce recomputation of splitting of string, and call super.validate().-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, invalidate, 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, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, revalidate, 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, update
-
-
-
-
Constructor Detail
-
PsMultiLineLabel
public PsMultiLineLabel()
Create label with empty text and left alignment.
-
PsMultiLineLabel
public PsMultiLineLabel(java.lang.String text)
Create label with given text in multiple lines, and left alignment. Text is wrapped at end of canvas size and whenever a '\n' appears.- See Also:
PsMultiLineLabel(),PsMultiLineLabel(String, int)
-
PsMultiLineLabel
public PsMultiLineLabel(java.lang.String text, int align)Create label with given text in multiple lines and given alignment. Text is wrapped at end of canvas size and whenever a '\n' appears. UseLabel.CENTER, Label.LEFT, Label.RIGHTto specify the horizontal alignment of the text.- See Also:
PsMultiLineLabel(),PsMultiLineLabel(String)- Version:
- 21.07.03, 1.10 revised (kp) No longer call setAlignment() to prevent update().
-
-
Method Detail
-
getTextColor
public java.awt.Color getTextColor()
Get color of text, if null then default color of component is used.- Since:
- JavaView 3.52.002
- Version:
- 15.08.04, 1.00 created (kp)
-
setTextColor
public void setTextColor(java.awt.Color color)
Set color of text, if null then default color of component is used.- Since:
- JavaView 3.52.002
- Version:
- 15.08.04, 1.00 created (kp)
-
getAlignment
public int getAlignment()
Get alignment of label. Alignment isLabel.CENTER, Label.LEFT, Label.RIGHTto specify the horizontal alignment of the text.
-
setAlignment
public void setAlignment(int align)
Same as injava.awt.Label. UseLabel.CENTER, Label.LEFT, Label.RIGHTto specify the horizontal alignment of the text.
-
getText
public java.lang.String getText()
Get text on this multi line label.- Returns:
- String contains the contents of this label
-
setText
public void setText(java.lang.String text)
Set text on this multi line label.- Parameters:
text- String contains the contents of this label
-
paint
public void paint(java.awt.Graphics g)
Draw split string if splitting was successful, otherwise just return without any drawing.- Overrides:
paintin classjava.awt.Component
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Get preferred layout size of this component.- Overrides:
getPreferredSizein classjava.awt.Component
-
validate
public void validate()
Enforce recomputation of splitting of string, and call super.validate(). Also invokes a repaint() because we are running as lightweight component.- Overrides:
validatein classjava.awt.Component- Version:
- 04.06.04, 1.10 revised (kp) Validate() now also invokes a repaint().
-
-
"