|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.swing.visuals.LabelView
public class LabelView
LabelView is a class that can display lines of text, an image, or both. The text can be
single or multiline. The text can also be horizontally or vertically oriented and aligned.
Notes:
System.getProperty("line.separator")
.
You can specify where in the label's display area the label's contents are aligned by setting the vertical and horizontal alignment. By default, labels are vertically centered in their display area. Text-only labels are leading edge aligned, by default; image-only labels are horizontally centered, by default.
You can also specify the position of the text relative to the image. By default, text is on the trailing edge of the image, with the text and image vertically aligned.
A label's leading and trailing edge are determined from the value of its
ComponentOrientation
property. At present, the default
ComponentOrientation setting maps the leading edge to left and the trailing
edge to right.
You can also specify if the text is painted horizontally or vertically. By default, text is painted horizontally. Each line of text can be set to indivdually align with the horizontal alignment property, or the text can be aligned as one block of text. The default value is to align each line of text indivudally.
Also, you can specify whether the text should wrap across lines, and whether it should wrap on word boundaries or not. By default, the text wraps lines on word boundaries.
If the text is painted horizontally and the text paints beyond the widht of the label, the clipped proeprty can be set to paint the text with "..." to show text is not visible. The default value is true. Also, a pixel gap can be specfied to set the distance between lines, the default value is 0. This property is more likely to be used for vertical oriented text, but works for horizontal text as well.
Finally, you can use the setIconTextGap
method
to specify how many pixels
should appear between the text and the image.
The default is 4 pixels.
Field Summary | |
---|---|
protected int |
alignmentMode
|
static int |
BLOCK
An alignment mode that aligns the entire block of text in the label view according to the horizontal alignment property of the label view |
protected boolean |
clipped
|
static int |
INDIVIDUAL
An alignment mode that aligns each line of text in the label view indivually according to the horizontal alignment property of the label view |
protected int |
leadingContentOffset
|
protected int |
lineGap
|
protected boolean |
lineWrap
|
protected int |
orientation
|
protected java.awt.Dimension |
preferredSpanSize
|
protected boolean |
replaceNewline
|
protected boolean |
replaceTab
|
static int |
SPAN_FILL
|
protected int |
tabSize
|
protected int |
topContentOffset
|
protected boolean |
wordWrap
|
Fields inherited from interface com.sas.swing.Constants |
---|
CENTER_BOTTOM, CENTER_LEADING, CENTER_LEFT, CENTER_RIGHT, CENTER_TOP, CENTER_TRAILING |
Constructor Summary | |
---|---|
LabelView()
Creates a LabelView instance with
no image and with an empty string for the title. |
|
LabelView(javax.swing.Icon image)
Creates a LabelView instance with the specified image. |
|
LabelView(javax.swing.Icon image,
int horizontalAlignment)
Creates a LabelView instance with the specified
image and horizontal alignment. |
|
LabelView(java.lang.String text)
Creates a LabelView instance with the specified text. |
|
LabelView(java.lang.String text,
javax.swing.Icon icon,
int horizontalAlignment)
Creates a LabelView instance with the specified
text, image, and horizontal alignment. |
|
LabelView(java.lang.String text,
int horizontalAlignment)
Creates a LabelView instance with the specified
text and horizontal alignment. |
Method Summary | |
---|---|
protected int |
checkHorizontalKey(int key,
java.lang.String message)
Verify that key is a legal value for the verticalAlignment or verticalTextPosition properties. |
protected int |
checkVerticalKey(int key,
java.lang.String message)
Verify that key is a legal value for the verticalAlignment or verticalTextPosition properties. |
int |
getAlignmentMode()
The alignment policy for the text in the label view. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns property information about the LabelView. |
int |
getGapBetweenLines()
The pixel gap between the lines of text. |
int |
getHorizontalAlignment()
Returns the alignment of the label's contents along the X axis. |
int |
getHorizontalTextPosition()
Returns the horizontal position of the label's text, relative to its image. |
int |
getLeadingContentOffset()
The number of pixels away from the horizontal alignment property the content is rendererd. |
boolean |
getLineWrap()
Gets the line-wrapping policy of the label view. |
int |
getOrientation()
Returns the orientation of the label, either HORIZONTAL or VERTICAL . |
java.awt.Dimension |
getPreferredSpanSize()
Returns a dimension which helps determine the preferred size of the label view. |
int |
getTabSize()
Gets the number of characters used to expand tabs. |
int |
getTopContentOffset()
The number of pixels away from the vertical alignment property the content is rendererd. |
java.lang.String |
getUIClassID()
Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component. |
int |
getVerticalAlignment()
Returns the alignment of the label's contents along the Y axis. |
int |
getVerticalTextPosition()
Returns the vertical position of the label's text, relative to its image. |
boolean |
getWrapStyleWord()
Get the style of wrapping used if the label view is wrapping lines. |
protected void |
initializeLocalVars()
Initializes label properties to their default values. |
boolean |
isClipped()
Returns whether the text is painted with "..." when not all visible. |
void |
setAlignmentMode(int newValue)
Sets the alignment policy for the text in the label view. |
void |
setClipped(boolean newValue)
Sets whether the text is painted with "..." when not all visible. |
void |
setGapBetweenLines(int newValue)
Sets the pixel gap between the lines of text. |
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 |
setLeadingContentOffset(int newValue)
Sets the number of pixels away from the horizontal alignment property the content is rendererd. |
void |
setLineWrap(boolean wrap)
Sets the line-wrapping policy of the label view. |
void |
setOrientation(int newValue)
Sets the orientation the text in the label is painted. |
void |
setPreferredSpanSize(java.awt.Dimension newSize)
Helps determine what the preferred size of the label view should be. |
void |
setTabSize(int newValue)
Sets the number of characters to expand tabs to. |
void |
setTopContentOffset(int newValue)
Sets the number of pixels away from the vertical alignment property the content is rendererd. |
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. |
void |
setWrapStyleWord(boolean word)
Set the style of wrapping used if the label view is wrapping lines. |
void |
updateUI()
Notification from the UIManager that the look and feel
(L&F) has changed. |
Field Detail |
---|
protected int alignmentMode
protected boolean clipped
protected int orientation
protected boolean lineWrap
protected boolean wordWrap
protected int lineGap
protected java.awt.Dimension preferredSpanSize
protected int tabSize
protected int leadingContentOffset
protected int topContentOffset
protected boolean replaceTab
protected boolean replaceNewline
public static final int INDIVIDUAL
public static final int BLOCK
public static final int SPAN_FILL
Constructor Detail |
---|
public LabelView(java.lang.String text, javax.swing.Icon icon, int horizontalAlignment)
LabelView
instance with the specified
text, image, and horizontal alignment.
The label view is horizontally oriented and centered vertically in its display area.
Line-wrapping is turned on, wrapping on word boundaries is possible.
The text is on the trailing edge of the image.
text
- The text to be displayed by the label view.icon
- The image to be displayed by the label view.horizontalAlignment
- One of the following constants
defined in SwingConstants
:
LEFT
,
CENTER
,
RIGHT
,
LEADING
or
TRAILING
.public LabelView(java.lang.String text, int horizontalAlignment)
LabelView
instance with the specified
text and horizontal alignment.
The label view is horizontally oriented and centered vertically in its display area.
Line-wrapping is turned on, wrapping on word boundaries is possible.
text
- The text to be displayed by the label view.horizontalAlignment
- One of the following constants
defined in SwingConstants
:
LEFT
,
CENTER
,
RIGHT
,
LEADING
or
TRAILING
.public LabelView(java.lang.String text)
LabelView
instance with the specified text.
The label view is horizontally oriented and centered vertically in its display area.
Line-wrapping is turned on, wrapping on word boundaries is possible.
The label is aligned against the leading edge of its display area.
text
- The text to be displayed by the label view.public LabelView(javax.swing.Icon image, int horizontalAlignment)
LabelView
instance with the specified
image and horizontal alignment.
The label view is horizontally oriented and centered vertically in its display area.
Line-wrapping is turned on, wrapping on word boundaries is possible.
image
- IconhorizontalAlignment
- One of the following constants
defined in SwingConstants
:
LEFT
,
CENTER
,
RIGHT
,
LEADING
or
TRAILING
.public LabelView(javax.swing.Icon image)
LabelView
instance with the specified image.
The label view is centered vertically and horizontally in its display area.
The label view is horizontally oriented and line-wrapping is turned on,
wrapping on word boundaries is possible.
image
- Iconpublic LabelView()
LabelView
instance with
no image and with an empty string for the title.
The label view is horizontally oriented and 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 and the lines will be wrapped on word boundaries when neccessary.
Method Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void updateUI()
UIManager
that the look and feel
(L&F) has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class javax.swing.JLabel
JComponent.updateUI()
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JLabel
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected void initializeLocalVars()
public int getAlignmentMode()
INDIVIDUAL
aligns each line of text in the label view indivually
according to the horizontal alignment property of the label view.
A mode of BLOCK
aligns the entire block of text in the label view
according to the horizontal alignment property of the label view.
The default value is INDIVIDUAL
.
JLabel.getHorizontalAlignment()
,
setAlignmentMode(int)
public void setAlignmentMode(int newValue)
INDIVIDUAL
aligns each line of text in the label view indivually
according to the horizontal alignment property of the label view.
A mode of BLOCK
aligns the entire block of text in the label view
according to the horizontal alignment property of the label view.
The default value is INDIVIDUAL
.
newValue
- the alignment policy for the text in the label viewJLabel.getHorizontalAlignment()
,
getAlignmentMode()
public boolean isClipped()
setClipped(boolean)
public void setClipped(boolean newValue)
newValue
- whether to paint text as clipped when it extends beyond the label's widthisClipped()
public int getOrientation()
HORIZONTAL
or VERTICAL
.
The default value is HORIZONTAL
.
setOrientation(int)
public void setOrientation(int newValue)
HORIZONTAL
or VERTICAL
.
The default value is HORIZONTAL
.
newValue
- indicates the orientation the text should be painted,
valid values one of the following constants defined in SwingConstants
:
HORIZONTAL
,
VERTICAL
getOrientation()
public int getGapBetweenLines()
setGapBetweenLines(int)
public void setGapBetweenLines(int newValue)
newValue
- the pixel gap space between lines of horizontal or vertical textgetGapBetweenLines()
public int getLeadingContentOffset()
setLeadingContentOffset(int)
public void setLeadingContentOffset(int newValue)
newValue
- the number of pixels to offset the content horizontallygetLeadingContentOffset()
public int getTopContentOffset()
setTopContentOffset(int)
public void setTopContentOffset(int newValue)
newValue
- the number of pixels to offset the content verticallygetTopContentOffset()
public void setLineWrap(boolean wrap)
wrap
- indicates if lines should be wrapped.getLineWrap()
public boolean getLineWrap()
public void setWrapStyleWord(boolean word)
word
- indicates if word boundaries should be used
for line wrapping.getWrapStyleWord()
public boolean getWrapStyleWord()
setWrapStyleWord(boolean)
public void setPreferredSpanSize(java.awt.Dimension newSize)
-1
, the preferred size for that value will be set.
newSize
- the new dimension to use to help determine the preferred size of the label viewgetPreferredSpanSize()
public java.awt.Dimension getPreferredSpanSize()
setPreferredSpanSize(Dimension)
public int getTabSize()
setTabSize(int)
public void setTabSize(int newValue)
newValue
- number of characters to expand togetTabSize()
protected int checkVerticalKey(int key, java.lang.String message)
checkVerticalKey
in class javax.swing.JLabel
key
- the property value to checkmessage
- the IllegalArgumentException detail message
java.lang.IllegalArgumentException
- if key isn't TOP, CENTER, BOTTOM, CENTER_TOP, or CENTER_BOTTOM.setVerticalAlignment(int)
,
setVerticalTextPosition(int)
protected int checkHorizontalKey(int key, java.lang.String message)
checkHorizontalKey
in class javax.swing.JLabel
key
- the property value to checkmessage
- the IllegalArgumentException detail message
java.lang.IllegalArgumentException
- if key isn't TOP, CENTER, BOTTOM, LEADING, TRAILING,
CENTER_LEFT, CENTER_RIGHT, CENTER_LEADING, or CENTER_TRAILING.setVerticalAlignment(int)
,
setVerticalTextPosition(int)
public int getVerticalAlignment()
getVerticalAlignment
in class javax.swing.JLabel
SwingConstants
or Constants
:
TOP
,
CENTER
,
BOTTOM
,
CENTER_TOP
, or
CENTER_BOTTOM
.SwingConstants
,
Constants
,
setVerticalAlignment(int)
public void setVerticalAlignment(int alignment)
setVerticalAlignment
in class javax.swing.JLabel
alignment
- One of the following constants
defined in SwingConstants
or Constants
:
TOP
,
CENTER
(the default),
BOTTOM
,
CENTER_TOP
, or
CENTER_BOTTOM
.SwingConstants
,
Constants
,
getVerticalAlignment()
public int getHorizontalAlignment()
getHorizontalAlignment
in class javax.swing.JLabel
SwingConstants
or Constants
:
LEFT
,
CENTER
,
RIGHT
,
LEADING
,
TRAILING
,
CENTER_LEFT
,
CENTER_RIGHT
,
CENTER_LEADING
, or
CENTER_TRAILING
.setHorizontalAlignment(int)
,
SwingConstants
,
Constants
public void setHorizontalAlignment(int alignment)
setHorizontalAlignment
in class javax.swing.JLabel
alignment
- One of the following constants
defined in SwingConstants
or Constants
:
LEFT
,
CENTER
(the default for image-only labels),
RIGHT
,
LEADING
(the default for text-only labels),
TRAILING
,
CENTER_LEFT
,
CENTER_RIGHT
,
CENTER_LEADING
, or
CENTER_TRAILING
.SwingConstants
,
Constants
,
getHorizontalAlignment()
public int getVerticalTextPosition()
getVerticalTextPosition
in class javax.swing.JLabel
SwingConstants
or Constants
:
TOP
,
CENTER
,
BOTTOM
,
CENTER_TOP
, or
CENTER_BOTTOM
.setVerticalTextPosition(int)
,
SwingConstants
,
Constants
public void setVerticalTextPosition(int textPosition)
setVerticalTextPosition
in class javax.swing.JLabel
textPosition
- One of the following constants
defined in SwingConstants
or Constants
:
TOP
,
CENTER
(the default),
BOTTOM
,
CENTER_TOP
, or
CENTER_BOTTOM
.SwingConstants
,
Constants
,
getVerticalTextPosition()
public int getHorizontalTextPosition()
getHorizontalTextPosition
in class javax.swing.JLabel
SwingConstants
or Constants
:
LEFT
,
CENTER
,
RIGHT
,
LEADING
,
TRAILING
,
CENTER_LEFT
,
CENTER_RIGHT
,
CENTER_LEADING
, or
CENTER_TRAILING
.SwingConstants
,
Constants
public void setHorizontalTextPosition(int textPosition)
setHorizontalTextPosition
in class javax.swing.JLabel
textPosition
- One of the following constants
defined in SwingConstants
or Constants
:
LEFT
,
CENTER
,
RIGHT
,
LEADING
,
TRAILING
(the default),
CENTER_LEFT
,
CENTER_RIGHT
,
CENTER_LEADING
, or
CENTER_TRAILING
.
java.lang.IllegalArgumentException
SwingConstants
,
Constants
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |