public class LabelWidget extends Widget
It allows to set 4 types of horizontal and vertical alignments (by default LEFT as horizontal and BASELINE as vertical).
Swing Font-hinting feature may cause the labels are not rendered completely.
Using setUseGlyphVector
you may force the label to be converted to a glyph vector
which scales correctly for any zoom factor.
Modifier and Type | Class and Description |
---|---|
static class |
LabelWidget.Alignment
The text alignment
|
static class |
LabelWidget.Orientation
The text orientation
|
static class |
LabelWidget.VerticalAlignment
The text vertical alignment
|
Widget.Dependency
Constructor and Description |
---|
LabelWidget(Scene scene)
Creates a label widget.
|
LabelWidget(Scene scene,
String label)
Creates a label widget with a label.
|
Modifier and Type | Method and Description |
---|---|
protected Rectangle |
calculateClientArea()
Calculates a client area for the label.
|
LabelWidget.Alignment |
getAlignment()
Returns a text horizontal alignment.
|
String |
getLabel()
Returns a label.
|
LabelWidget.Orientation |
getOrientation()
Gets a text orientation.
|
LabelWidget.VerticalAlignment |
getVerticalAlignment()
Gets a text vertical alignment.
|
boolean |
isPaintAsDisabled()
Returns whether the label is painted as disabled.
|
boolean |
isUseGlyphVector()
Returns whether the label widget is using glyph vector for rendering text.
|
protected void |
paintWidget()
Paints the label widget.
|
void |
setAlignment(LabelWidget.Alignment alignment)
Sets a text horizontal alignment.
|
void |
setLabel(String label)
Sets a label.
|
void |
setOrientation(LabelWidget.Orientation orientation)
Sets a text orientation.
|
void |
setPaintAsDisabled(boolean paintAsDisabled)
Sets whether the label is painted as disabled.
|
void |
setUseGlyphVector(boolean useGlyphVector)
Sets whether the label widget is using glyph vector for rendering text.
|
void |
setVerticalAlignment(LabelWidget.VerticalAlignment verticalAlignment)
Sets a text vertical alignment.
|
addChild, addChild, addChild, addChild, addChildren, addDependency, bringToBack, bringToFront, convertLocalToScene, convertLocalToScene, convertSceneToLocal, convertSceneToLocal, createActions, equals, getAccessibleContext, getActions, getActions, getBackground, getBorder, getBounds, getChildConstraint, getChildren, getClientArea, getCursor, getCursorAt, getDependencies, getFont, getForeground, getGraphics, getLayout, getLocation, getLookup, getMaximumSize, getMinimumSize, getParentWidget, getPreferredBounds, getPreferredLocation, getPreferredSize, getResourceTable, getScene, getState, getToolTipText, hashCode, isCheckClipping, isEnabled, isHitAt, isOpaque, isPreferredBoundsSet, isRepaintRequiredForRevalidating, isValidated, isVisible, notifyAdded, notifyBackgroundChanged, notifyFontChanged, notifyForegroundChanged, notifyRemoved, notifyStateChanged, paint, paintBackground, paintBorder, paintChildren, removeChild, removeChildren, removeChildren, removeDependency, removeFromParent, repaint, resolveBounds, revalidate, revalidate, setAccessibleContext, setBackground, setBackgroundFromResource, setBorder, setBorder, setCheckClipping, setChildConstraint, setCursor, setEnabled, setFont, setFontFromResource, setForeground, setForegroundFromResource, setLayout, setMaximumSize, setMinimumSize, setOpaque, setPreferredBounds, setPreferredLocation, setPreferredSize, setResourceTable, setState, setToolTipText, setVisible, updateResources
public LabelWidget(Scene scene)
scene
- the scenepublic String getLabel()
public void setLabel(String label)
label
- the labelpublic LabelWidget.Alignment getAlignment()
public void setAlignment(LabelWidget.Alignment alignment)
alignment
- the text horizontal alignmentpublic LabelWidget.VerticalAlignment getVerticalAlignment()
public void setVerticalAlignment(LabelWidget.VerticalAlignment verticalAlignment)
verticalAlignment
- the text vertical alignmentpublic LabelWidget.Orientation getOrientation()
public void setOrientation(LabelWidget.Orientation orientation)
orientation
- the text orientationpublic boolean isPaintAsDisabled()
public void setPaintAsDisabled(boolean paintAsDisabled)
paintAsDisabled
- if true, then the label is painted as disabledpublic boolean isUseGlyphVector()
public void setUseGlyphVector(boolean useGlyphVector)
Note that using glyph vector could slow-down the rendering performance. Note that if you are not using glyph vector then the text may be clipped when a scene has zoom factor different from 1.0.
useGlyphVector
- if true, then a glyph vector is used for rendering textprotected Rectangle calculateClientArea()
calculateClientArea
in class Widget
protected void paintWidget()
paintWidget
in class Widget