com.sas.awt
Class Label

com.sas.awt.Label
All Implemented Interfaces:
VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.lang.StringDataInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.PublicClonable, com.sas.ViewDefaultModelInterface, com.sas.ViewInterface, MultipleValueEventSourceInterface, ResizeToFitInterface, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.accessibility.Accessible

public class Label
implements com.sas.PublicClonable, com.sas.lang.StringDataInterface, ResizeToFitInterface, com.sas.ViewDefaultModelInterface

Label is a component that displays a single line of read-only text. The text can be aligned within the label (left aligned, centered, or right aligned). The default is left alignment. If text is not specified, the label is created with default text of "Label". Label does not accept key events.

Creation:

  1. Create a Label with no specified text

    Label label1 = new Label();
    label1.initialize();

  2. Create a Label with the specified text

    Label label1 = new Label("My Text");
    label1.initialize();

    where "My Text" is the text that will appear on the label

  3. Create a Label with the specified text and alignment

    Label label1 = new Label("My Text", alignment);
    label1.initialize();

    where:

  4. Create a new Label with the specified text obtained from a resource bundle

    Label label1 = new Label(RB.getResources(), resourceKey);
    label1.initialize();

    where resourceKey identifies a String in the resource bundle


Default Size:
Required Interfaces:
Label requires a model that implements the com.sas.lang.StringData interface. A default model is automatically created and attached to the label when the label is initially constructed.

Notes:

See Also:
Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
Label()
          Default constructor
Label(java.util.ResourceBundle bundle, java.lang.String textID)
          Create a new Label with the specified text obtained from a resource bundle
Label(java.lang.String text)
          Create a new Label with the specified text
Label(java.lang.String text, int alignment)
          Create a new Label with the specified text and alignment
 
Method Summary
 void addNotify()
          Notify the component that it has been added to a container and that the peer should be created.
 void attachModel(com.sas.ModelInterface model)
          Attaches a model to the component.
 java.lang.Object clone()
          Clones the component
 void detachModel(com.sas.ModelInterface model)
          Detaches the current model and attaches the default model if the model is set to null
static int getDefaultHeight()
          Returns the default height for instances of this class
static int getDefaultWidth()
          Returns the default width for instances of this class
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns the ExtendedBeanInfo for this class.
 java.util.Vector getRequiredInterfaces()
          Returns the required interfaces Vector for this component.
 boolean isDefaultModelAttached()
          Returns whether the default model is attached.
 boolean isResizeToFit()
          Returns the value of the resizeToFit property The resizeToFit property determines whether to change the size of the component when either the text or font changes.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Processes a PropertyChangeEvent sent by the model.
 void refresh()
          Sets the Label text from the text obtained from the attached model
 void refresh(com.sas.ModelInterface model)
          Sets the label text from the text obtained from the attached model
 void setAlignment(int alignment)
          Sets the text alignment for the label to the specified alignment (Label.LEFT (0), Label.CENTER (1), or Label.RIGHT (2)).
static void setDefaultHeight(int newDefaultHeight)
          Sets the default height of the component.
 void setDefaultValues()
          Sets the initial values to the properties.
static void setDefaultWidth(int newDefaultWidth)
          Sets the default width of the component.
 void setFont(java.awt.Font font)
          Sets the font to be used by the component for displaying text.
 void setResizeToFit(boolean resizeToFit)
          Sets the value of the resizeToFit property The resizeToFit property determines whether to change the size of the component when either the text or font changes.
 void setText(java.lang.String text)
          Sets the text to the specified text
 
Methods inherited from class com.sas.awt.LabelVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachView, computePreferredSize, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getMinimumSize, getModelInterface, getPreferredSize, getPrePainter, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initialize, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, paint, queryLinks, queryLinks, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setBounds, setComponentDescription, setComponentSupportInfo, setEnabled, setFocus, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setModelInterface, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, update, validateObject
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

Label

public Label()
Default constructor


Label

public Label(java.lang.String text)
Create a new Label with the specified text

Parameters:
text - label text

Label

public Label(java.lang.String text,
             int alignment)
Create a new Label with the specified text and alignment

Parameters:
text - text that appears on the label
alignment - an integer that specifies the text alignment within the label (Label.LEFT,Label.CENTER,Label.RIGHT)

Label

public Label(java.util.ResourceBundle bundle,
             java.lang.String textID)
Create a new Label with the specified text obtained from a resource bundle

Parameters:
bundle - resource bundle
text - textID identifier in the resource bundle
Method Detail

getDefaultWidth

public static int getDefaultWidth()
Returns the default width for instances of this class

Returns:
the default width in pixels
See Also:
setDefaultWidth(int)

setDefaultWidth

public static void setDefaultWidth(int newDefaultWidth)
Sets the default width of the component. The default width will be used by webAF when creating this component.

Parameters:
newDefaultWidth - the new default width in pixels
See Also:
getDefaultWidth()

getDefaultHeight

public static int getDefaultHeight()
Returns the default height for instances of this class

Returns:
the default height in pixels
See Also:
setDefaultHeight(int)

setDefaultHeight

public static void setDefaultHeight(int newDefaultHeight)
Sets the default height of the component. The default height will be used by webAF when creating this component.

Parameters:
newDefaultHeight - the new default height in pixels
See Also:
getDefaultHeight()

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns the ExtendedBeanInfo for this class.

Returns:
ExtendedBeanInfo for this class

addNotify

public void addNotify()
Notify the component that it has been added to a container and that the peer should be created. If resizeToFit is set to true, the component may be resized if the font or text has changed.

Overrides:
addNotify in class java.awt.Label

attachModel

public void attachModel(com.sas.ModelInterface model)
Attaches a model to the component. Listens for PropertyChangeEvents from the model.

Specified by:
attachModel in interface com.sas.ViewInterface
Overrides:
attachModel in class LabelVisualComponent
Parameters:
model - model to attach
See Also:
ViewInterface.attachModel(com.sas.ModelInterface)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the component

Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class LabelVisualComponent
Returns:
new instance of the Label
Throws:
java.lang.CloneNotSupportedException - if the model attached to the component being cloned will not allow the clone to attach.

detachModel

public void detachModel(com.sas.ModelInterface model)
Detaches the current model and attaches the default model if the model is set to null

Specified by:
detachModel in interface com.sas.ViewInterface
Overrides:
detachModel in class LabelVisualComponent
Parameters:
model - Model to detach
See Also:
ViewInterface.detachModel(com.sas.ModelInterface)

getRequiredInterfaces

public java.util.Vector getRequiredInterfaces()
Returns the required interfaces Vector for this component.

Specified by:
getRequiredInterfaces in interface com.sas.ViewInterface
Overrides:
getRequiredInterfaces in class LabelVisualComponent
Returns:
the required interfaces Vector for this component.
See Also:
ViewInterface.getRequiredInterfaces()

isDefaultModelAttached

public boolean isDefaultModelAttached()
Returns whether the default model is attached.

Specified by:
isDefaultModelAttached in interface com.sas.ViewDefaultModelInterface
Returns:
whether the default model is attached.

isResizeToFit

public boolean isResizeToFit()
Returns the value of the resizeToFit property The resizeToFit property determines whether to change the size of the component when either the text or font changes.

Specified by:
isResizeToFit in interface ResizeToFitInterface
Returns:
value of the resizeToFit property
See Also:
setResizeToFit(boolean)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Processes a PropertyChangeEvent sent by the model.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class LabelVisualComponent
Parameters:
event - The event from the model indicating what property changed
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

refresh

public void refresh()
Sets the Label text from the text obtained from the attached model


refresh

public void refresh(com.sas.ModelInterface model)
Sets the label text from the text obtained from the attached model

Specified by:
refresh in interface com.sas.ViewInterface
Overrides:
refresh in class LabelVisualComponent
Parameters:
model - attached model
See Also:
ViewInterface.refresh(com.sas.ModelInterface)

setAlignment

public void setAlignment(int alignment)
Sets the text alignment for the label to the specified alignment (Label.LEFT (0), Label.CENTER (1), or Label.RIGHT (2)). Specifying any other value will result in a java.lang.IllegalArgumentException to be thrown.

Overrides:
setAlignment in class java.awt.Label
Parameters:
alignment - alignment value (Label.LEFT (0), Label.CENTER (1), or Label.RIGHT (2))

setDefaultValues

public void setDefaultValues()
Sets the initial values to the properties. This method is called by the Component constructors. The setDefaultValues method of each class is responsible for setting its own initial values.

Specified by:
setDefaultValues in interface VisualInterface
Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class LabelVisualComponent
See Also:
ComponentInterface.setDefaultValues()

setFont

public void setFont(java.awt.Font font)
Sets the font to be used by the component for displaying text.

Specified by:
setFont in interface VisualInterface
Overrides:
setFont in class LabelVisualComponent
Parameters:
font - font
See Also:
Component.setFont(java.awt.Font), LabelVisualComponent.getFont()

setResizeToFit

public void setResizeToFit(boolean resizeToFit)
Sets the value of the resizeToFit property The resizeToFit property determines whether to change the size of the component when either the text or font changes. If the component is managed by a layout manager that uses preferred sizes, the component will behave as if the resizeToFit property has been set to true regardless of the actual value of the resizeToFit property.

Specified by:
setResizeToFit in interface ResizeToFitInterface
Parameters:
resizeToFit - boolean value
See Also:
isResizeToFit()

setText

public void setText(java.lang.String text)
Sets the text to the specified text

Specified by:
setText in interface com.sas.lang.StringDataInterface
Overrides:
setText in class java.awt.Label
Parameters:
text - label text
See Also:
Label.getText()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.