org.netbeans.api.visual 2.23.1

org.netbeans.api.visual.widget
Class LabelWidget

java.lang.Object
  extended by org.netbeans.api.visual.widget.Widget
      extended by org.netbeans.api.visual.widget.LabelWidget
All Implemented Interfaces:
Accessible
Direct Known Subclasses:
ListItemWidget

public class LabelWidget
extends Widget

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
static class LabelWidget.Alignment
          The text alignment
static class LabelWidget.Orientation
          The text orientation
static class LabelWidget.VerticalAlignment
          The text vertical alignment
 
Nested classes/interfaces inherited from class org.netbeans.api.visual.widget.Widget
Widget.Dependency
 
Constructor Summary
LabelWidget(Scene scene)
          Creates a label widget.
LabelWidget(Scene scene, String label)
          Creates a label widget with a label.
 
Method Summary
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.
 
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelWidget

public LabelWidget(Scene scene)
Creates a label widget.

Parameters:
scene - the scene

LabelWidget

public LabelWidget(Scene scene,
                   String label)
Creates a label widget with a label.

Parameters:
scene - the scene
label - the label
Method Detail

getLabel

public String getLabel()
Returns a label.

Returns:
the label

setLabel

public void setLabel(String label)
Sets a label.

Parameters:
label - the label

getAlignment

public LabelWidget.Alignment getAlignment()
Returns a text horizontal alignment.

Returns:
the text horizontal alignment

setAlignment

public void setAlignment(LabelWidget.Alignment alignment)
Sets a text horizontal alignment.

Parameters:
alignment - the text horizontal alignment

getVerticalAlignment

public LabelWidget.VerticalAlignment getVerticalAlignment()
Gets a text vertical alignment.

Returns:
the text vertical alignment

setVerticalAlignment

public void setVerticalAlignment(LabelWidget.VerticalAlignment verticalAlignment)
Sets a text vertical alignment.

Parameters:
verticalAlignment - the text vertical alignment

getOrientation

public LabelWidget.Orientation getOrientation()
Gets a text orientation.

Returns:
the text orientation
Since:
2.1

setOrientation

public void setOrientation(LabelWidget.Orientation orientation)
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

protected Rectangle calculateClientArea()
Calculates a client area for the label.

Overrides:
calculateClientArea in class Widget
Returns:
the client area

paintWidget

protected void paintWidget()
Paints the label widget.

Overrides:
paintWidget in class Widget

org.netbeans.api.visual 2.23.1

Built on September 7 2010.  |  Portions Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.