Class LabelWidget
java.lang.Object
org.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.widget.LabelWidget
- All Implemented Interfaces:
Accessible
,org.openide.util.Lookup.Provider
- Direct Known Subclasses:
ListItemWidget
A widget representing a text. The widget is not opaque and is checking clipping for by default.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The text alignmentstatic enum
The text orientationstatic enum
The text vertical alignmentNested classes/interfaces inherited from class org.netbeans.api.visual.widget.Widget
Widget.Dependency
-
Constructor Summary
ConstructorsConstructorDescriptionLabelWidget
(Scene scene) Creates a label widget.LabelWidget
(Scene scene, String label) Creates a label widget with a label. -
Method Summary
Modifier and TypeMethodDescriptionprotected Rectangle
Calculates a client area for the label.Returns a text horizontal alignment.getLabel()
Returns a label.Gets a text orientation.Gets a text vertical alignment.boolean
Returns whether the label is painted as disabled.boolean
Returns whether the label widget is using glyph vector for rendering text.protected void
Paints the label widget.void
setAlignment
(LabelWidget.Alignment alignment) Sets a text horizontal alignment.void
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.Methods inherited from class org.netbeans.api.visual.widget.Widget
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
-
Constructor Details
-
LabelWidget
-
LabelWidget
-
-
Method Details
-
getLabel
-
setLabel
-
getAlignment
Returns a text horizontal alignment.- Returns:
- the text horizontal alignment
-
setAlignment
Sets a text horizontal alignment.- Parameters:
alignment
- the text horizontal alignment
-
getVerticalAlignment
Gets a text vertical alignment.- Returns:
- the text vertical alignment
-
setVerticalAlignment
Sets a text vertical alignment.- Parameters:
verticalAlignment
- the text vertical alignment
-
getOrientation
Gets a text orientation.- Returns:
- the text orientation
- Since:
- 2.1
-
setOrientation
Sets a text orientation.- Parameters:
orientation
- the text orientation- Since:
- 2.1
-
isPaintAsDisabled
public boolean isPaintAsDisabled()Returns whether the label is painted as disabled.- Returns:
- true, if the label is painted as disabled
-
setPaintAsDisabled
public void setPaintAsDisabled(boolean paintAsDisabled) Sets whether the label is painted as disabled.- Parameters:
paintAsDisabled
- if true, then the label is painted as disabled
-
isUseGlyphVector
public boolean isUseGlyphVector()Returns whether the label widget is using glyph vector for rendering text.- Returns:
- true, if the label widget is using glyph vector
- Since:
- 2.7
-
setUseGlyphVector
public void setUseGlyphVector(boolean useGlyphVector) Sets whether the label widget is using glyph vector for rendering text.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.
- Parameters:
useGlyphVector
- if true, then a glyph vector is used for rendering text- Since:
- 2.7
-
calculateClientArea
Calculates a client area for the label.- Overrides:
calculateClientArea
in classWidget
- Returns:
- the client area
-
paintWidget
-