|
Diamond Control Suite 3.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent diamondedge.swing.DsLabel
public class DsLabel
DsLabel displays multiple lines of text and/or an icon that a user can't change directly. It is a replacement to and uses the same API as JLabel. It breaks the text up into multiple lines when WordWrap is turned on. Many other additional features are available such as rotation, margins, text styles (3D and highlighting), built-in borders, and font underlining and strikethrough.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface diamondedge.swing.DsConstants |
---|
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
DsLabel()
Creates a DsLabel without an icon and a blank string for the text. |
|
DsLabel(Icon icon)
Creates a DsLabel with an icon which is centered vertically and horizontally. |
|
DsLabel(Icon icon,
int horizontalAlignment)
Creates a DsLabel with an icon which is centered vertically and the specified horizontal alignment. |
|
DsLabel(String text)
Creates a DsLabel with the specified text and without an icon. |
|
DsLabel(String text,
Icon icon,
int horizontalAlignment)
Creates a DsLabel with the specified text, icon and horizontal alignment. |
|
DsLabel(String text,
int horizontalAlignment)
|
Method Summary | |
---|---|
void |
addTextListener(TextListener l)
Adds the specified text listener to receive text events |
protected Border |
createBorder()
|
protected void |
fireLabelChangedEvent()
Fire an text event to the listeners |
Paint |
getBackgroundPaint()
|
int |
getCenterBorder()
Returns whether to draw a border in between the InnerBorder and the OuterBorder. |
Icon |
getDisabledIcon()
Returns the graphic image (glyph, icon) that the label displays when the label is disabled. |
char |
getDisplayedMnemonic()
Returns the character that indicates a mnemonic key. |
int |
getFontUnderline()
Returns a value that determines how the text for the label is underlined. |
Paint |
getForegroundPaint()
|
int |
getHorizontalAlignment()
Returns the horizontal alignment of the contents (text and icon) within the Label |
int |
getHorizontalTextPosition()
Returns the horizontal position of the text relative to the icon |
Icon |
getIcon()
Returns the graphic image (glyph, icon) that the label displays. |
int |
getIconTextGap()
Returns the amount of space between the text and the icon displayed in this label. |
int |
getInnerBorder()
Returns whether to draw a border inside of the CenterBorder. |
Insets |
getInsets()
Returns the insets which includes the border's insets and the margin. |
Insets |
getInsets(Insets insets)
Returns the insets which includes the border's insets and the margin. |
Component |
getLabelFor()
Get the component this is labelling. |
Color |
getLineBorderColor()
Returns the color used to draw the line border. |
int |
getLineBorderWidth()
Returns the width of the line border drawn around the label. |
Insets |
getMargins()
Returns the spacing between the border and the contents (text/icon). |
Dimension |
getMinimumSize()
This method is called when the layout manager wants to know the bare minimum amount of space we need to get by. |
int |
getOuterBorder()
Returns whether to draw a border on the outside of the label but inside of the outline if it exists. |
Dimension |
getPreferredSize()
This method is called by a layout manager when it wants to know how big we'd like to be. |
int |
getRotation()
Returns the degrees to rotate text and icon. |
String |
getText()
Returns the text that the label displays |
Color |
getTextOutlineColor()
Returns the color used to draw an outline around each character of the text. |
double |
getTextOutlineWidth()
Returns the width of the outline drawn around each character in the text. |
int |
getTextStyle()
Returns a value that determines how the text is drawn. |
int |
getVerticalAlignment()
Returns the vertical alignment of the contents (text and icon) within the Label |
int |
getVerticalTextPosition()
Returns the vertical position of the text relative to the icon |
boolean |
isAutoSize()
Returns a value that determines whether the label is automatically resized to display its entire contents. |
boolean |
isFontStrikeThrough()
Returns a value that determines whether the text for the label is displayed with a line through the text. |
boolean |
isWordWrap()
Returns a value that determines whether the text should be wrapped to a new line when it reaches the trailing margin. |
protected void |
paintComponent(Graphics g)
|
void |
removeTextListener(TextListener l)
Removes the specified text listener so it no longer receives text events. |
void |
setAutoSize(boolean s)
Sets a value that determines whether the label is automatically resized to display its entire contents. |
void |
setBackground(Color c)
|
void |
setBackgroundPaint(Paint p)
|
protected void |
setBorders()
|
void |
setBounds(int x,
int y,
int width,
int height)
Moves and resizes this component. |
void |
setCenterBorder(int val)
Creates a border in between the InnerBorder and the OuterBorder. |
void |
setDisabledIcon(Icon icon)
Defines the icon this component will display when the label is disabled. |
void |
setDisplayedMnemonic(char mnemonicChar)
Specify a character that indicates a mnemonic key. |
void |
setFont(Font f)
|
void |
setFontStrikeThrough(boolean strikeThrough)
Sets a value that determines whether the text for the label is displayed with a line through the text. |
void |
setFontUnderline(int underline)
Sets a value that determines how the text for the label is underlined. |
void |
setForeground(Color c)
Sets the text color (ForegroundPaint property). |
void |
setForegroundPaint(Paint p)
|
void |
setHorizontalAlignment(int align)
Sets the horizontal alignment of the contents (text and icon) within the Label. |
void |
setHorizontalTextPosition(int textPosition)
Sets the horizontal position of the text relative to the icon. |
void |
setIcon(Icon icon)
Defines the icon this component will display. |
void |
setIconTextGap(int iconTextGap)
If both the icon and text properties are set, this property defines the space between them. |
void |
setInnerBorder(int val)
Creates a border on the inside of the CenterBorder. |
void |
setLabelFor(Component c)
Specify the component on which the label will call the requestFocus method when the mnemonic is activated. |
void |
setLineBorderColor(Color c)
Sets the color used to draw the line border. |
void |
setLineBorderWidth(int lineWidth)
Sets the width of the line border drawn around the label. |
void |
setMargins(Insets margins)
Sets the spacing between the border and the contents (text/icon). |
void |
setOuterBorder(int val)
Creates a border on the outside of the label but inside of the outline if it exists. |
void |
setRotation(int val)
Set the degrees to rotate the text and icon. |
void |
setText(String text)
Sets the text that the label displays. |
void |
setTextOutlineColor(Color c)
Sets the color used to draw an outline around each character of the text. |
void |
setTextOutlineWidth(double lineWidth)
Sets the width of the outline drawn around each character in the text. |
void |
setTextStyle(int style)
Sets a value that determines how the text is drawn. |
void |
setVerticalAlignment(int a)
Sets the vertical alignment of the contents (text and icon) within the Label. |
void |
setVerticalTextPosition(int textPosition)
Sets the vertical position of the text relative to the icon. |
void |
setWordWrap(boolean s)
Sets a value that determines whether the text should be wrapped to a new line when it reaches the trailing margin. |
void |
updateUI()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DsLabel(String text, Icon icon, int horizontalAlignment)
text
- The text displayed in the label.icon
- The icon displayed next to the text.horizontalAlignment
- The horizontal alignment of the contents (text and icon) within the Label. One of: LEFT, CENTER, RIGHT, LEADING or TRAILING
public DsLabel(String text)
public DsLabel(String text, int horizontalAlignment)
public DsLabel(Icon icon)
public DsLabel(Icon icon, int horizontalAlignment)
horizontalAlignment
- - One of: LEFT, CENTER, RIGHT, LEADING or TRAILING
public DsLabel()
Method Detail |
---|
public void updateUI()
updateUI
in class JComponent
public void setForeground(Color c)
setForeground
in class JComponent
public Paint getForegroundPaint()
public void setForegroundPaint(Paint p)
public void setBackground(Color c)
setBackground
in class JComponent
public Paint getBackgroundPaint()
public void setBackgroundPaint(Paint p)
public boolean isAutoSize()
public void setAutoSize(boolean s)
public boolean isWordWrap()
public void setWordWrap(boolean s)
public int getHorizontalAlignment()
public void setHorizontalAlignment(int align)
LEFT - contents are left-aligned. CENTER - contents are centered. RIGHT - contents are right-aligned. LEADING - contents are aligned to the leading edge (at the beginning). (Default) TRAILING- contents are aligned to the trailing edge (at the end).
public int getVerticalAlignment()
public void setVerticalAlignment(int a)
TOP - contents are aligned to the top. CENTER - contents are centered. (Default) BOTTOM - contents are aligned to the bottom.
public int getHorizontalTextPosition()
public void setHorizontalTextPosition(int textPosition)
LEFT - text is on the left side of the icon. CENTER - text and icon are centered horizontally. RIGHT - text is on the right side. LEADING - text is on the leading edge of the icon (at the beginning). TRAILING- text is on the trailing edge of the icon (at the end). (Default)
public int getVerticalTextPosition()
public void setVerticalTextPosition(int textPosition)
TOP - text is on the top of the icon. CENTER - text and icon are centered vertically. (Default) BOTTOM - text is on the bottom of the icon.
public char getDisplayedMnemonic()
setDisplayedMnemonic(char)
public void setDisplayedMnemonic(char mnemonicChar)
mnemonicChar
- a char specifying the mnemonic to displaysetLabelFor(Component)
public Component getLabelFor()
setDisplayedMnemonic(char)
public void setLabelFor(Component c)
setDisplayedMnemonic(char)
public String getText()
public void setText(String text)
public Icon getIcon()
public void setIcon(Icon icon)
The default value of this property is null.
setVerticalTextPosition(int)
,
setHorizontalTextPosition(int)
public Icon getDisabledIcon()
public void setDisabledIcon(Icon icon)
The default value of this property is null.
setVerticalTextPosition(int)
,
setHorizontalTextPosition(int)
public int getIconTextGap()
setIconTextGap(int)
public void setIconTextGap(int iconTextGap)
The default value of this property is 4 pixels.
public Insets getInsets()
getInsets
in class JComponent
public Insets getInsets(Insets insets)
getInsets
in class JComponent
public Insets getMargins()
public void setMargins(Insets margins)
public void setFont(Font f)
setFont
in class JComponent
public boolean isFontStrikeThrough()
public void setFontStrikeThrough(boolean strikeThrough)
public int getFontUnderline()
public void setFontUnderline(int underline)
NONE
- no underline drawn
SINGLE
- single line drawn at the baseline
DOUBLE
- double line drawn at the baseline
ACCOUNTING
- single line drawn below the descent
public int getTextStyle()
public void setTextStyle(int style)
FLAT
- draw text normally
RAISED
- make text look like it raised off the screen with a bevel
LOWERED
- make text look like it inset into the screen
RAISED_LIGHT
- make text look like it raised off the screen but without the shadow
LOWERED_LIGHT
- make text look like it inset into the screen but without the shadow
RAISED and LOWERED
look good with larger or bold fonts. For smaller fonts use
RAISED_LIGHT and LOWERED_LIGHT
public Color getTextOutlineColor()
public void setTextOutlineColor(Color c)
public void setTextOutlineWidth(double lineWidth)
public double getTextOutlineWidth()
public void addTextListener(TextListener l)
l
- the text listenerpublic void removeTextListener(TextListener l)
l
- the text listenerprotected void fireLabelChangedEvent()
public void setBounds(int x, int y, int width, int height)
x
and y
, and the
new size is specified by width
and height
.
Overriden to ignore width and height when autoSize is turned on.
setBounds
in class Component
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public Dimension getMinimumSize()
getMinimumSize
in class JComponent
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
public int getRotation()
public void setRotation(int val)
val
- degrees to rotate from horizontal (only valid values: 0, 90, 270)public Color getLineBorderColor()
public void setLineBorderColor(Color c)
public int getLineBorderWidth()
public void setLineBorderWidth(int lineWidth)
public int getOuterBorder()
public void setOuterBorder(int val)
val
- One of: NONE, RAISED, LOWERED, ETCHED_RAISED, ETCHED, SINGLE_LINE
public int getCenterBorder()
public void setCenterBorder(int val)
val
- One of: RAISED, LOWERED, ETCHED_RAISED, ETCHED, SINGLE_LINE
public int getInnerBorder()
public void setInnerBorder(int val)
val
- One of: NONE, RAISED, LOWERED, ETCHED_RAISED, ETCHED, SINGLE_LINE
protected Border createBorder()
protected void setBorders()
|
Diamond Control Suite 3.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |