|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.visuals.BaseButton
public abstract class BaseButton
BaseButton is an abstract class for creating a button. The button can display both
a label and an IconInterface object arranged in several different alignments.
It sends an ActionEvent when pressed and an ItemEvent if selected.
The interaction between the Models and Listeners can be described as follows. There
is essentially three parts of the BaseButton. The visual component, Button, the Listener, and
the Model. The Listener listens for user events on the Button. The Model listens to the
Listener and applies state changes to the Model. Then the visual Button component listens
to the Model for the state changes and applies it to the Button.
Notes:
PushButton
,
ToggleButton
,
ButtonListenerInterface
,
ButtonModelInterface
,
DefaultButtonListener
,
DefaultButtonModel
,
Serialized FormField Summary | |
---|---|
protected java.lang.String |
actionCommand
|
protected java.awt.event.ActionListener |
actionListenerList
|
protected boolean |
borderPainted
|
static int |
BOTTOM
|
protected ButtonListenerInterface |
buttonListener
|
protected ButtonModelInterface |
buttonModel
|
protected java.awt.Insets |
currentInsets
|
protected com.sas.visuals.IconInterface |
defaultIcon
|
protected com.sas.visuals.IconInterface |
disabledIcon
|
protected com.sas.util.transforms.TransformInterface |
displayTransform
|
protected int |
focusGap
|
protected boolean |
focusPainted
|
protected int |
gap
|
protected boolean |
hasFocus
|
protected int |
horizontalAlignment
|
protected int |
horizontalTextAlignment
|
protected java.lang.Object |
item
|
protected java.awt.event.ItemListener |
itemListenerList
|
static int |
LEFT
|
protected com.sas.visuals.IconInterface |
pressedIcon
|
static java.lang.String |
RB_KEY
|
protected boolean |
resizeToFit
|
static int |
RIGHT
|
protected com.sas.visuals.IconInterface |
rolloverIcon
|
protected com.sas.visuals.IconInterface |
selectedIcon
|
protected java.lang.String |
text
|
protected int |
textPosition
|
static int |
TOP
|
protected boolean |
updateItem
|
protected boolean |
updateText
|
protected int |
verticalAlignment
|
protected int |
verticalTextAlignment
|
Fields inherited from interface com.sas.visuals.Alignment |
---|
BEGIN, CENTER, END |
Constructor Summary | |
---|---|
BaseButton()
Default Constructor |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
Invoked when the buttonModel sends an ActionEvent. |
void |
addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener to listen for ActionEvents on the BaseButton |
void |
addItemListener(java.awt.event.ItemListener listener)
Add an ItemListener to listen for ItemEvents on the BaseButton |
void |
addNotify()
Makes this Component displayable by connecting it to a native screen resource. |
protected void |
buttonModelArmed(ButtonModelInterface btnModel)
Handle change in buttonModel armed property. |
protected void |
buttonModelDisabled(ButtonModelInterface btnModel)
Handle change in buttonModel disabled property. |
protected void |
buttonModelPressed(ButtonModelInterface btnModel)
Handle change in buttonModel pressed property. |
protected void |
buttonModelRollover(ButtonModelInterface btnModel)
Handle change in buttonModel rollover property. |
protected void |
buttonModelSelected(ButtonModelInterface btnModel)
Handle change in buttonModel selected property. |
java.lang.Object |
clone()
Returns a BaseButton clone of the original BaseButton component called upon |
java.awt.Dimension |
computePreferredSize()
Compute the preferred size. |
void |
detachModel(com.sas.ModelInterface model)
Detaches model from the BaseButton |
void |
focusGained(java.awt.event.FocusEvent evt)
Invoked when a component gains the keyboard focus. |
void |
focusLost(java.awt.event.FocusEvent evt)
Invoked when a component loses the keyboard focus. |
java.lang.String |
getActionCommand()
Get the actionCommand to be set on an ActionEvent when it is sent. |
ButtonListenerInterface |
getButtonListener()
Get the ButtonListenerInterface object that controls the state of the ButtonModelInterface object. |
ButtonModelInterface |
getButtonModel()
Get the ButtonModelInterface object that contains the state of the BaseButton. |
protected java.awt.Dimension |
getContentSize(java.awt.Dimension textSize,
java.awt.Dimension iconSize)
Get the size of the content to be displayed within the BaseButton. |
com.sas.visuals.IconInterface |
getDefaultIcon()
Get the default IconInterface object displayed normally. |
com.sas.visuals.IconInterface |
getDisabledIcon()
Get the IconInterface displayed if the buttonModel state is "disabled". |
com.sas.util.transforms.TransformInterface |
getDisplayTransform()
Get the TransformInterface used to transform the model information to the format and type to be displayed. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
|
int |
getFocusGap()
Get the pixel amount of gap between the border and the focus rectangle. |
int |
getHorizontalAlignment()
Get the horizontal alignment of the content of the button. |
int |
getHorizontalTextAlignment()
Get the horizontal alignment of the text displayed on the button. |
int |
getIconTextGap()
Get the gap between the IconInterface object and where the text is drawn. |
java.awt.Insets |
getInsets()
Get the Insets of the BaseButton. |
java.lang.Object |
getItem()
Get the item that with the displayTransform is displayed on the button. |
char |
getKeyAccelerator()
Get the key accelerator used to trigger this button. |
com.sas.visuals.IconInterface |
getPressedIcon()
Get the IconInterface displayed when the buttonModel state is "pressed". |
java.util.Vector |
getRequiredInterfaces()
Returns the required interfaces Vector for this component. |
com.sas.visuals.IconInterface |
getRolloverIcon()
Get the IconInterface displayed when the buttonModel state is "rollover". |
com.sas.visuals.IconInterface |
getSelectedIcon()
Get the IconInterface displayed when the buttonModel state is "selected". |
java.lang.Object[] |
getSelectedObjects()
Get the item value in a one-element array of Objects. |
java.lang.String |
getText()
Get the text displayed in the button. |
int |
getTextPosition()
Get the position the text is displayed relative to the defaultIcon. |
int |
getVerticalAlignment()
Get the vertical alignment of the content displayed on the button. |
int |
getVerticalTextAlignment()
Get the vertical alignment of the text displayed on the button. |
boolean |
isBorderPainted()
Get if the Border object is painted. |
boolean |
isFocusPainted()
Get if the focus rectangle is painted. |
boolean |
isFocusTraversable()
Get that the button is FocusTraversable. |
boolean |
isResizeToFit()
Get if the button will resizeToFit if the contentSize changes. |
boolean |
isSelected()
Get the selected state of the ButtonModelInterface object |
void |
itemStateChanged(java.awt.event.ItemEvent event)
Invoked when the selected state of the buttonModel is changed. |
protected void |
processActionEvent(java.awt.event.ActionEvent e)
Process ActionEvents sent from the button to its listeners |
protected void |
processEvent(java.awt.AWTEvent e)
Process events |
protected void |
processItemEvent(java.awt.event.ItemEvent e)
Process ItemEvents sent from the button to its listeners |
void |
propertyChange(java.beans.PropertyChangeEvent event)
Invoked when a PropertyChangeEvent occurs. |
void |
refresh(com.sas.ModelInterface model)
Refresh the model attached to the BaseButton |
protected void |
refreshItem(java.lang.Object newItem)
Refresh the contents displayed with the new Item value. |
void |
removeActionListener(java.awt.event.ActionListener listener)
Remove an ActionListener from the list of listeners to be notified of an ActionEvent. |
void |
removeItemListener(java.awt.event.ItemListener listener)
Remove an ItemListener from the list of listeners to be notified of an ItemEvent. |
void |
resizeToFit()
Resize the button to fit the preferred size. |
void |
setActionCommand(java.lang.String cmd)
Set the actionCommand to be sent out when an ActionEvent is triggered. |
void |
setBorderPainted(boolean paint)
Set whether the border is painted. |
void |
setBounds(int x,
int y,
int width,
int height)
Set the bounds of the BaseButton. |
void |
setButtonListener(ButtonListenerInterface btnListener)
Set the buttonListener for the BaseButton. |
void |
setButtonModel(ButtonModelInterface model)
Set the buttonModel for the BaseButton. |
void |
setDefaultIcon(com.sas.visuals.IconInterface defaultImg)
Set the default IconInterface object. |
void |
setDefaultValues()
Set the default internal values for the BaseButton. |
void |
setDisabledIcon(com.sas.visuals.IconInterface disabledImg)
Set the IconInterface object to be painted when the button is disabled. |
void |
setDisplayTransform(com.sas.util.transforms.TransformInterface transform)
Set the Transform to be used to display the "item" property. |
void |
setEnabled(boolean b)
Set the button enabled state. |
void |
setFocusGap(int g)
Set the gap between the border and the focus rectangle. |
void |
setFocusPainted(boolean paint)
Set whether the focus rectangle should be painted. |
void |
setFont(java.awt.Font f)
Set the font to be used to display the text of the BaseButton. |
void |
setHorizontalAlignment(int horizontalAlign)
Set the horizontal alignment of the content of the BaseButton. |
void |
setHorizontalTextAlignment(int hTextAlign)
Set the horizontal alignment of the text of the BaseButton. |
void |
setIconTextGap(int g)
Set the pixel gap between the IconInterface object and the text. |
void |
setInsets(java.awt.Insets insets)
Set the insets between the edge of the button and the content of the button. |
void |
setItem(java.lang.Object newItem)
Set the item object that is transformed by the displayTransform for display as the content of the BaseButton. |
void |
setKeyAccelerator(char key)
Set the key to that when pressed triggers the BaseButton. |
void |
setPressedIcon(com.sas.visuals.IconInterface pressedImg)
Set the IconInterface object to be painted when the BaseButton state is pressed. |
void |
setResizeToFit(boolean resize)
Set whether the BaseButton should be resized automatically to fit the contents when they are changed. |
void |
setRolloverIcon(com.sas.visuals.IconInterface rolloverImg)
Set the IconInterface object to be painted when the BaseButton state is rollover. |
void |
setSelected(boolean selected)
Set the button state to selected. |
void |
setSelectedIcon(com.sas.visuals.IconInterface selectedImg)
Set the IconInterface object to be painted when the BaseButton state is selected. |
void |
setText(java.lang.String txt)
Set the text to be displayed on the BaseButton. |
void |
setTextPosition(int position)
Set the position the text is displayed relative to the defaultIcon. |
void |
setVerticalAlignment(int verticalAlign)
Set the vertical alignment of the content displayed on the button. |
void |
setVerticalTextAlignment(int vTextAlign)
Set the vertical alignment of the text displayed on the button. |
Methods inherited from class com.sas.visuals.CompositeContainer |
---|
getDefaultHeight, getDefaultWidth, setDefaultHeight, setDefaultWidth |
Methods inherited from interface com.sas.awt.ContainerInterface |
---|
getComponents, getLayout, invalidate, setLayout, validate |
Field Detail |
---|
public static final java.lang.String RB_KEY
public static final int TOP
public static final int BOTTOM
public static final int LEFT
public static final int RIGHT
protected com.sas.visuals.IconInterface defaultIcon
protected com.sas.visuals.IconInterface disabledIcon
protected com.sas.visuals.IconInterface pressedIcon
protected com.sas.visuals.IconInterface rolloverIcon
protected com.sas.visuals.IconInterface selectedIcon
protected java.lang.Object item
protected java.lang.String actionCommand
protected java.lang.String text
protected int textPosition
protected int gap
protected int focusGap
protected java.awt.Insets currentInsets
protected com.sas.util.transforms.TransformInterface displayTransform
protected int verticalAlignment
protected int horizontalAlignment
protected int verticalTextAlignment
protected int horizontalTextAlignment
protected boolean resizeToFit
protected boolean focusPainted
protected boolean borderPainted
protected boolean hasFocus
protected ButtonListenerInterface buttonListener
protected ButtonModelInterface buttonModel
protected transient boolean updateText
protected transient boolean updateItem
protected transient java.awt.event.ActionListener actionListenerList
protected transient java.awt.event.ItemListener itemListenerList
Constructor Detail |
---|
public BaseButton()
Method Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- the ActionEvent from the buttonModelpublic void addActionListener(java.awt.event.ActionListener listener)
addActionListener
in interface ActionSource
listener
- the ActionListener to send the ActionEvents to.ActionListener
,
removeActionListener(java.awt.event.ActionListener)
public void addItemListener(java.awt.event.ItemListener listener)
addItemListener
in interface java.awt.ItemSelectable
listener
- the ItemListener to send the ItemEvents to.ItemListener
,
removeItemListener(java.awt.event.ItemListener)
public void addNotify()
addNotify
in interface ContainerInterface
addNotify
in class ContainerContainerComponent
protected void buttonModelArmed(ButtonModelInterface btnModel)
btnModel
- the buttonModel that changed.protected void buttonModelDisabled(ButtonModelInterface btnModel)
btnModel
- the buttonModel that changed.protected void buttonModelPressed(ButtonModelInterface btnModel)
btnModel
- the buttonModel that changed.protected void buttonModelRollover(ButtonModelInterface btnModel)
buttonModel.isDisabled() getDefaultIcon() == null getRolloverIcon() == null btnModel.isSelected() && getSelectedIcon() != null btnModel.isPressed() && getPressedIcon() != nullOverride to change the behavior when the model rollover property changes.
btnModel
- the Button Model that changed.protected void buttonModelSelected(ButtonModelInterface btnModel)
btnModel
- the Button Model that changed.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface com.sas.PublicClonable
clone
in class ContainerContainerComponent
java.lang.CloneNotSupportedException
- if it component cannot be cloned.public void focusGained(java.awt.event.FocusEvent evt)
focusGained
in interface java.awt.event.FocusListener
FocusListener.focusGained(java.awt.event.FocusEvent)
,
focusLost(java.awt.event.FocusEvent)
public void focusLost(java.awt.event.FocusEvent evt)
focusLost
in interface java.awt.event.FocusListener
FocusListener.focusLost(java.awt.event.FocusEvent)
,
focusGained(java.awt.event.FocusEvent)
public java.lang.String getActionCommand()
setActionCommand(java.lang.String)
,
ActionEvent.getActionCommand()
public ButtonListenerInterface getButtonListener()
setButtonListener(com.sas.visuals.ButtonListenerInterface)
public ButtonModelInterface getButtonModel()
setButtonModel(com.sas.visuals.ButtonModelInterface)
protected java.awt.Dimension getContentSize(java.awt.Dimension textSize, java.awt.Dimension iconSize)
textSize
- the size of the text to be displayediconSize
- the size of the defaultIcon to be displayed
public com.sas.visuals.IconInterface getDefaultIcon()
setDefaultIcon(com.sas.visuals.IconInterface)
public com.sas.visuals.IconInterface getDisabledIcon()
setDisabledIcon(com.sas.visuals.IconInterface)
public com.sas.util.transforms.TransformInterface getDisplayTransform()
setDisplayTransform(com.sas.util.transforms.TransformInterface)
public int getFocusGap()
setFocusGap(int)
public int getIconTextGap()
setIconTextGap(int)
public java.awt.Insets getInsets()
getInsets
in interface ContainerInterface
getInsets
in class ContainerContainerComponent
public java.lang.Object getItem()
SelectableInterface.getItem()
,
setItem(java.lang.Object)
public java.lang.String getText()
getText
in interface com.sas.lang.StringDataInterface
StringDataInterface.getText()
,
setText(java.lang.String)
public int getHorizontalAlignment()
setHorizontalAlignment(int)
public int getHorizontalTextAlignment()
setHorizontalTextAlignment(int)
public char getKeyAccelerator()
setKeyAccelerator(char)
public java.awt.Dimension computePreferredSize()
computePreferredSize
in interface VisualInterface
computePreferredSize
in class ContainerVisualComponent
VisualInterface.computePreferredSize()
public com.sas.visuals.IconInterface getPressedIcon()
setPressedIcon(com.sas.visuals.IconInterface)
public java.util.Vector getRequiredInterfaces()
getRequiredInterfaces
in interface com.sas.ViewInterface
getRequiredInterfaces
in class ContainerVisualComponent
ViewInterface.getRequiredInterfaces()
public com.sas.visuals.IconInterface getRolloverIcon()
setRolloverIcon(com.sas.visuals.IconInterface)
public com.sas.visuals.IconInterface getSelectedIcon()
setSelectedIcon(com.sas.visuals.IconInterface)
public java.lang.Object[] getSelectedObjects()
getSelectedObjects
in interface java.awt.ItemSelectable
ItemSelectable
public int getTextPosition()
setTextPosition(int)
public int getVerticalAlignment()
setVerticalAlignment(int)
public int getVerticalTextAlignment()
setVerticalTextAlignment(int)
public boolean isBorderPainted()
setBorderPainted(boolean)
public boolean isFocusPainted()
isFocusPainted()
public boolean isFocusTraversable()
isFocusTraversable
in class java.awt.Component
Component.isFocusTraversable()
public boolean isResizeToFit()
isResizeToFit
in interface ResizeToFitInterface
ResizeToFitInterface.isResizeToFit()
,
setResizeToFit(boolean)
public boolean isSelected()
setSelected(boolean)
public void itemStateChanged(java.awt.event.ItemEvent event)
itemStateChanged
in interface java.awt.event.ItemListener
ItemListener.itemStateChanged(java.awt.event.ItemEvent)
protected void processEvent(java.awt.AWTEvent e)
processEvent
in class java.awt.Container
protected void processActionEvent(java.awt.event.ActionEvent e)
protected void processItemEvent(java.awt.event.ItemEvent e)
public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
propertyChange
in class ContainerVisualComponent
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)
public void detachModel(com.sas.ModelInterface model)
detachModel
in interface com.sas.ViewInterface
detachModel
in class ContainerVisualComponent
ModelInterface
- of the BaseButtonViewInterface.detachModel(com.sas.ModelInterface)
public void refresh(com.sas.ModelInterface model)
refresh
in interface com.sas.ViewInterface
refresh
in class ContainerVisualComponent
ModelInterface
- of the BaseButton.ViewInterface.refresh(com.sas.ModelInterface)
protected void refreshItem(java.lang.Object newItem)
public void removeActionListener(java.awt.event.ActionListener listener)
removeActionListener
in interface ActionSource
listener
- an object which handles ActionEvent eventsActionListener
,
addActionListener(java.awt.event.ActionListener)
public void removeItemListener(java.awt.event.ItemListener listener)
removeItemListener
in interface java.awt.ItemSelectable
ItemListener
,
addItemListener(java.awt.event.ItemListener)
public void resizeToFit()
setResizeToFit(boolean)
,
isResizeToFit()
public void setActionCommand(java.lang.String cmd)
cmd
- new Action CommandgetActionCommand()
public void setBorderPainted(boolean paint)
paint
- If true, the border is painted, false border is not painted.isBorderPainted()
public void setBounds(int x, int y, int width, int height)
setBounds
in interface VisualInterface
setBounds
in class ContainerVisualComponent
x
- the x positiony
- the y positionwidth
- the width of the buttonheight
- the height of the buttonVisualInterface.setBounds(int, int, int, int)
public void setButtonListener(ButtonListenerInterface btnListener)
btnListener
- the buttonListenergetButtonListener()
public void setButtonModel(ButtonModelInterface model)
model
- the buttonModelgetButtonModel()
public void setDefaultIcon(com.sas.visuals.IconInterface defaultImg)
defaultImg
- the defaultImagegetDefaultIcon()
public void setDefaultValues()
setDefaultValues
in interface ContainerInterface
setDefaultValues
in interface VisualInterface
setDefaultValues
in interface com.sas.ComponentInterface
setDefaultValues
in class CompositeContainer
ContainerInterface.setDefaultValues()
public void setDisabledIcon(com.sas.visuals.IconInterface disabledImg)
disabledImg
- the disabledIconsetDisabledIcon(com.sas.visuals.IconInterface)
public void setDisplayTransform(com.sas.util.transforms.TransformInterface transform)
transform
- the display transformgetDisplayTransform()
public void setEnabled(boolean b)
setEnabled
in interface VisualInterface
setEnabled
in class ContainerVisualComponent
b
- If true the button is enabled, if false, the button is disabled.VisualInterface.setEnabled(boolean)
public void setFocusGap(int g)
g
- - the pixel gap between the border and the focusRectangle.getFocusGap()
public void setFocusPainted(boolean paint)
paint
- If true, the focus rectangle will be painted, if false, it will not.isFocusPainted()
public void setFont(java.awt.Font f)
setFont
in interface VisualInterface
setFont
in class ContainerVisualComponent
f
- the text fontVisualInterface.setFont(java.awt.Font)
public void setIconTextGap(int g)
g
- the pixels between where the icon and the text are painted.getIconTextGap()
public void setHorizontalAlignment(int horizontalAlign)
horizontalAlign
- the horizontal alignment: LEFT(BEGIN), CENTER, or RIGHT(END)getHorizontalAlignment()
public void setHorizontalTextAlignment(int hTextAlign)
hTextAlign
- the horizontal text alignment: LEFT(BEGIN), CENTER, or RIGHT(END)getHorizontalTextAlignment()
public void setInsets(java.awt.Insets insets)
setInsets
in interface ContainerInterface
setInsets
in class ContainerContainerComponent
public void setItem(java.lang.Object newItem)
SelectableInterface.setItem(java.lang.Object)
,
getItem()
public void setKeyAccelerator(char key)
key
- the character that triggers the BaseButtongetKeyAccelerator()
public void setPressedIcon(com.sas.visuals.IconInterface pressedImg)
pressedImg
- the pressedIcongetPressedIcon()
public void setResizeToFit(boolean resize)
setResizeToFit
in interface ResizeToFitInterface
resize
- If true, the BaseButton is resized when the contents are changed, if false, the size is
not changed when the contents change.ResizeToFitInterface.setResizeToFit(boolean)
,
isResizeToFit()
public void setRolloverIcon(com.sas.visuals.IconInterface rolloverImg)
rolloverImg
- the rolloverIcongetRolloverIcon()
public void setSelected(boolean selected)
selected
- the selected state of the buttonisSelected()
public void setSelectedIcon(com.sas.visuals.IconInterface selectedImg)
selectedImg
- the selectedIcongetSelectedIcon()
public void setText(java.lang.String txt)
setText
in interface com.sas.lang.StringDataInterface
txt
- the text of the BaseButtongetText()
public void setTextPosition(int position)
position
- the textPosition: TOP, BOTTOM, LEFT, or RIGHT.getTextPosition()
public void setVerticalAlignment(int verticalAlign)
verticalAlign
- the vertical alignment: TOP, CENTER, or BOTTOMgetVerticalAlignment()
public void setVerticalTextAlignment(int vTextAlign)
vTextAlign
- the vertical text alignment: TOP, CENTER, or BOTTOMgetVerticalTextAlignment()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |