All Packages Class Hierarchy This Package Previous Next Index
Class symantec.itools.awt.WrappingLabel
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----symantec.itools.awt.WrappingLabel
- public class WrappingLabel
- extends Canvas
- implements AlignStyle
This class implements a multiple-line text label.
It displays text on one or more lines, wrapping text
as needed to fit in the available horizontal space.
-
align
- The current text alignment.
-
baseline
- The maximum ascent of the font used to display text.
-
fm
- The metrics of the font used to display text.
-
text
- The text string being displayed.
-
WrappingLabel()
- Constructs a default wrapping label.
-
WrappingLabel(String)
- Constructs a wrapping label that displays the specified string.
-
WrappingLabel(String, int)
- Constructs wrapping label with the specified text and alignment.
-
drawAlignedString(Graphics, String, int, int, int)
- This helper method draws a string aligned the requested way.
-
getAlignStyle()
- Gets the current text alignment setting.
-
getText()
- Gets the current label text.
-
paint(Graphics)
- Paints this component using the given graphics context.
-
paramString()
- Returns an empty string.
-
reshape(int, int, int, int)
- Moves and/or resizes this component.
-
resize(int, int)
- Resizes this component.
-
setAlignStyle(int)
- Sets the text alignment.
-
setText(String)
- Sets the label text.
text
protected String text
- The text string being displayed.
align
protected int align
- The current text alignment.
One of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT.
- See Also:
- AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
baseline
protected int baseline
- The maximum ascent of the font used to display text.
fm
protected FontMetrics fm
- The metrics of the font used to display text.
WrappingLabel
public WrappingLabel()
- Constructs a default wrapping label. Default values are an empty text string
and left alignment.
WrappingLabel
public WrappingLabel(String s)
- Constructs a wrapping label that displays the specified string.
The label will default to left alignment.
- Parameters:
- s - string to be displayed in label
WrappingLabel
public WrappingLabel(String s,
int a)
- Constructs wrapping label with the specified text and alignment.
- Parameters:
- s - the string to be displayed in label
- a - the alignment, one of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
- See Also:
- AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
getAlignStyle
public int getAlignStyle()
- Gets the current text alignment setting.
- Returns:
- the current alignment, one of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
- See Also:
- setAlignStyle, AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
setAlignStyle
public void setAlignStyle(int a)
- Sets the text alignment.
- Parameters:
- a - the new alignment style, one of ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
- See Also:
- getAlignStyle, AlignStyle, ALIGN_LEFT, ALIGN_CENTERED, ALIGN_RIGHT
getText
public String getText()
- Gets the current label text.
- Returns:
- the label's text string
- See Also:
- setText
setText
public void setText(String s)
- Sets the label text.
- Parameters:
- s - the new label text
- See Also:
- getText
paramString
public String paramString()
- Returns an empty string.
This is a standard Java AWT method which typically returns a string
representing the state of this object.
- Returns:
- the empty string
- Overrides:
- paramString in class Component
reshape
public synchronized void reshape(int x,
int y,
int width,
int height)
- Moves and/or resizes this component.
This is a standard Java AWT method which gets called to move and/or
resize this component. Components that are in containers with layout
managers should not call this method, but rely on the layout manager
instead.
It is overridden here to re-wrap the text as necessary.
- Parameters:
- x - horizontal position in the parent's coordinate space
- y - vertical position in the parent's coordinate space
- width - the new width
- height - the new height
- Overrides:
- reshape in class Component
resize
public synchronized void resize(int width,
int height)
- Resizes this component.
This is a standard Java AWT method which gets called to
resize this component. Components that are in containers with layout
managers should not call this method, but rely on the layout manager
instead.
It is overridden here to re-wrap the text as necessary.
- Parameters:
- width - the new width, in pixels
- height - the new height, in pixels
- Overrides:
- resize in class Component
paint
public void paint(Graphics g)
- Paints this component using the given graphics context.
This is a standard Java AWT method which typically gets called
by the AWT to handle painting this component. It paints this component
using the given graphics context. The graphics context clipping region
is set to the bounding rectangle of this component and its <0,0>
coordinate is this component's top-left corner.
- Parameters:
- g - the graphics context used for painting
- Overrides:
- paint in class Canvas
- See Also:
- repaint, update
drawAlignedString
protected void drawAlignedString(Graphics g,
String s,
int x,
int y,
int width)
- This helper method draws a string aligned the requested way.
- Parameters:
- g - the graphics context used for painting
- s - the string to draw
- x - the point to start drawing from, x coordinate
- y - the point to start drawing from, y coordinate
- width - the width of the area to draw in, in pixels
All Packages Class Hierarchy This Package Previous Next Index