com.sas.awt
Class Button

com.sas.awt.Button
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 Button
implements com.sas.PublicClonable, com.sas.lang.StringDataInterface, ResizeToFitInterface, com.sas.ViewDefaultModelInterface

Button is a pushbutton component that can display a specified text label.

Creation:

  1. Create a Button with no specified text

    Button button1 = new Button();
    button1.initialize();

  2. Create a Button with the specified text

    Button button1 = new Button("My Text");
    button1.initialize();

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

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

Events:
Button sends out an ActionEvent when it is clicked.

Notes:

See Also:
Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
Button()
          Default constructor
Button(java.lang.String text)
          Create a Button with the specified text
 
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
 java.awt.Dimension computePreferredSize()
          Returns the preferred size of 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.
 java.lang.String getText()
          Returns the Button label.
 boolean isDefaultModelAttached()
          Returns whether the default model is attached.
 boolean isResizeToFit()
          Returns the value of the resizeToFit property.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Processes a PropertyChangeEvent sent by the model.
 void refresh()
          Sets text for the Button component from the text obtained from the attached model
 void refresh(com.sas.ModelInterface model)
          Set text for the Button from the text obtained from the attached model
 void setActionCommand(java.lang.String command)
          Sets the string that will be included in any ActionEvents that are generated by the Button
static void setDefaultHeight(int newDefaultHeight)
          Sets the default height of the component.
 void setDefaultValues()
          Sets the initial values to the default values.
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 setLabel(java.lang.String label)
          Sets the Button with the specified 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 Button with the specified text.
 
Methods inherited from class com.sas.awt.ButtonVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachView, 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

Button

public Button()
Default constructor


Button

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

Parameters:
text - text that will appear on the button
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 label has changed.

Overrides:
addNotify in class java.awt.Button

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 ButtonVisualComponent
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 ButtonVisualComponent
Returns:
new instance of the Button
Throws:
java.lang.CloneNotSupportedException - if the model attached to the component being cloned will not allow the clone to attach.

computePreferredSize

public java.awt.Dimension computePreferredSize()
Returns the preferred size of the component

Specified by:
computePreferredSize in interface VisualInterface
Overrides:
computePreferredSize in class ButtonVisualComponent
Returns:
preferred size
See Also:
VisualInterface.computePreferredSize()

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 ButtonVisualComponent
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 ButtonVisualComponent
Returns:
the required interfaces Vector for this component.
See Also:
ViewInterface.getRequiredInterfaces()

getText

public java.lang.String getText()
Returns the Button label. This method is an alias for getLabel().

Specified by:
getText in interface com.sas.lang.StringDataInterface
Returns:
Button label
See Also:
setText(java.lang.String)

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 ButtonVisualComponent
Parameters:
event - The event from the model indicating what property changed
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

refresh

public void refresh()
Sets text for the Button component from the text obtained from the attached model


refresh

public void refresh(com.sas.ModelInterface model)
Set text for the Button from the text obtained from the attached model

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

setActionCommand

public void setActionCommand(java.lang.String command)
Sets the string that will be included in any ActionEvents that are generated by the Button

Overrides:
setActionCommand in class java.awt.Button
Parameters:
command - command string to be included in any ActionEvents
See Also:
Button.getActionCommand()

setDefaultValues

public void setDefaultValues()
Sets the initial values to the default values. 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 ButtonVisualComponent
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 ButtonVisualComponent
Parameters:
font - font
See Also:
Component.setFont(java.awt.Font), ButtonVisualComponent.getFont()

setLabel

public void setLabel(java.lang.String label)
Sets the Button with the specified text

Overrides:
setLabel in class java.awt.Button
Parameters:
label - Button text
See Also:
Button.getLabel()

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 Button with the specified text. This method is an alias for setLabel(String).

Specified by:
setText in interface com.sas.lang.StringDataInterface
Parameters:
text - Button text
See Also:
getText()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.