|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.visuals.ToggleButton
public class ToggleButton
ToggleButton is a subclass of BaseButton that creates a button where images and text, or both
can be displayed. The button can be selected and then pressed and deselected.
When the button is pressed both an ActionEvent and an ItemEvent are sent to any listeners.
The text and images can be aligned horizontally and vertically.
Notes:
ToggleButton toggleButton1 = new ToggleButton();
IconInterface defaultIcon = new ImageView("d:/someImage.gif");
toggleButton1.setDefaultIcon( defaultIcon );
toggleButton1.setText("Button");
// to change behavior to RadioButton style
SelectionGroup selectionGroup1 = new SelectionGroup();
toggleButton1.setSelectionGroup( selectionGroup1 );
BaseButton,
Serialized Form| Field Summary | |
|---|---|
protected java.awt.Point |
contentShift
Point value that specifies the amount the ToggleButton shifts when pressed. |
protected LabelView |
label
A LabelView object used in the ToggleButton to display the text. |
static java.lang.String |
RB_KEY
|
protected java.awt.Rectangle |
textBounds
Rectangle object that represents the outer bounds of the text to be
displayed on the ToggleButton. |
| Fields inherited from class com.sas.visuals.BaseButton |
|---|
actionCommand, actionListenerList, borderPainted, BOTTOM, buttonListener, buttonModel, currentInsets, defaultIcon, disabledIcon, displayTransform, focusGap, focusPainted, gap, hasFocus, horizontalAlignment, horizontalTextAlignment, item, itemListenerList, LEFT, pressedIcon, resizeToFit, RIGHT, rolloverIcon, selectedIcon, text, textPosition, TOP, updateItem, updateText, verticalAlignment, verticalTextAlignment |
| Fields inherited from interface com.sas.visuals.Alignment |
|---|
BEGIN, CENTER, END |
| Constructor Summary | |
|---|---|
ToggleButton()
Default constructor. |
|
ToggleButton(com.sas.visuals.IconInterface defaultImg)
Constructor that sets the default image to be displayed. |
|
ToggleButton(java.lang.String txt)
Constructor that sets the text to be displayed. |
|
ToggleButton(java.lang.String txt,
com.sas.visuals.IconInterface defaultImg)
Constructor that sets both the default image and the text to be displayed. |
|
ToggleButton(java.lang.String txt,
com.sas.visuals.IconInterface defaultImg,
boolean selected)
Constructor that sets the default image, the text to be displayed, and the selected state of the ToggleButton. |
|
| Method Summary | |
|---|---|
protected void |
buttonModelArmed(ButtonModelInterface btnModel)
Handles change in buttonModel armed property. |
protected void |
buttonModelPressed(ButtonModelInterface btnModel)
Handles change in buttonModel pressed property. |
protected void |
buttonModelSelected(ButtonModelInterface btnModel)
Handles change in buttonModel selected property. |
java.lang.Object |
clone()
Create a clone of the ToggleButton. |
protected java.awt.Point |
contentShift()
Returns the amount to shift the contents based on the state of the button model and the icons that have been set. |
java.awt.Point |
getContentShift()
Gets the amount the content is shifted when the button is pressed or selected. |
static int |
getDefaultHeight()
Gets the default height of the ToggleButton |
static int |
getDefaultWidth()
Gets the default width of the ToggleButton |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this ToggleButton. |
java.awt.Dimension |
getMinimumSize()
Get the minimum size of the ToggleButton. |
SelectionGroupInterface |
getSelectionGroup()
Gets the selectionGroup to control the behavior of the ToggleButton. |
java.lang.String |
getSource()
Gets the source of the image displayed as the default image. |
protected java.awt.Rectangle |
getTextBounds()
Gets the bounds of the text. |
void |
paint(java.awt.Graphics g)
Paint the ToggleButton in its current state based on the buttonModel. |
protected void |
paintBackground(java.awt.Graphics g)
Paints the background on the ToggleButton. |
protected void |
paintFocus(java.awt.Graphics g)
Paints the focus Rectangle on the ToggleButton. |
void |
setContentShift(java.awt.Point pt)
Sets the amount the content is shifted when the button is pressed or selected. |
static void |
setDefaultHeight(int newHeight)
Sets the default height of the ToggleButton |
static void |
setDefaultWidth(int newWidth)
Sets the default width of the ToggleButton in pixels |
void |
setFont(java.awt.Font f)
Set the font of the text on the ToggleButton. |
void |
setHorizontalTextAlignment(int hAlign)
Set the horizontal alignment of the text of the ToggleButton. |
void |
setSelected(boolean s)
Set the selected state of the ToggleButton. |
void |
setSelectionGroup(SelectionGroupInterface sGroup)
Sets the selectionGroup to control the behavior of the ToggleButton. |
void |
setSource(java.lang.String src)
Set the source of the image displayed as the default image. |
void |
setText(java.lang.String txt)
Sets the text to be displayed on the ToggleButton. |
void |
setVerticalTextAlignment(int vAlign)
Sets the vertical alignment of the text displayed on the button. |
| Methods inherited from interface com.sas.visuals.SelectableInterface |
|---|
getButtonModel, getDisplayTransform, getItem, setDisplayTransform, setItem |
| Methods inherited from interface com.sas.awt.ContainerInterface |
|---|
getComponents, getLayout, invalidate, setLayout, validate |
| Field Detail |
|---|
protected LabelView label
LabelView object used in the ToggleButton to display the text.
protected transient java.awt.Rectangle textBounds
Rectangle object that represents the outer bounds of the text to be
displayed on the ToggleButton.
protected java.awt.Point contentShift
Point value that specifies the amount the ToggleButton shifts when pressed.
public static java.lang.String RB_KEY
| Constructor Detail |
|---|
public ToggleButton()
public ToggleButton(java.lang.String txt)
txt - the text to display on the ToggleButtonpublic ToggleButton(com.sas.visuals.IconInterface defaultImg)
defaultImg - the default image to display on the ToggleButton
public ToggleButton(java.lang.String txt,
com.sas.visuals.IconInterface defaultImg)
txt - the text to display on the ToggleButtondefaultImg - the default image to display on the ToggleButton
public ToggleButton(java.lang.String txt,
com.sas.visuals.IconInterface defaultImg,
boolean selected)
txt - the text to display on the ToggleButtondefaultImg - the default image to display on the ToggleButtonselected - the selected state of the ToggleButton| Method Detail |
|---|
public static int getDefaultHeight()
setDefaultHeight(int)public static int getDefaultWidth()
setDefaultWidth(int)public static void setDefaultHeight(int newHeight)
newHeight - the desired default height in pixelsgetDefaultHeight()public static void setDefaultWidth(int newWidth)
newWidth - the desired default width in pixelsgetDefaultWidth()public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector to
augment the automatically introspected information about this ToggleButton.
protected void buttonModelArmed(ButtonModelInterface btnModel)
buttonModelArmed in class BaseButtonbtnModel - the buttonModel that changed.protected void buttonModelPressed(ButtonModelInterface btnModel)
buttonModelPressed in class BaseButtonbtnModel - the buttonModel that changed.protected void buttonModelSelected(ButtonModelInterface btnModel)
buttonModelSelected in class BaseButtonbtnModel - the Button Model that changed.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface com.sas.PublicClonableclone in class BaseButtonjava.lang.CloneNotSupportedException - if clone creation failsprotected java.awt.Point contentShift()
public java.awt.Dimension getMinimumSize()
getMinimumSize in interface VisualInterfacegetMinimumSize in class ContainerVisualComponentVisualInterface.getMinimumSize()public void paint(java.awt.Graphics g)
paint in class ContainerVisualComponentg - the Graphics context.VisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)public void setFont(java.awt.Font f)
setFont in interface VisualInterfacesetFont in class BaseButtonf - the font of the ToggleButton textVisualInterface.setFont(java.awt.Font)public void setHorizontalTextAlignment(int hAlign)
setHorizontalTextAlignment in class BaseButtonhAlign - protected int value derived from com.sas.geometry.OrientaionsBaseButton.setHorizontalTextAlignment(int),
Orientationspublic SelectionGroupInterface getSelectionGroup()
getSelectionGroup in interface SelectableInterfaceSelectionGroupprotected java.awt.Rectangle getTextBounds()
protected void paintBackground(java.awt.Graphics g)
g - the Graphics contextprotected void paintFocus(java.awt.Graphics g)
g - the Graphics contextpublic void setSelectionGroup(SelectionGroupInterface sGroup)
setSelectionGroup in interface SelectableInterfacesGroup - the selectionGroup to add the ToggleButton to.SelectionGrouppublic java.awt.Point getContentShift()
setContentShift(java.awt.Point)public void setContentShift(java.awt.Point pt)
pt - the point to translate the contents postion by when
the button is pressed or selected.getContentShift()public void setSelected(boolean s)
setSelected in class BaseButtons - the selected state of the ToggleButton.BaseButton.isSelected()public java.lang.String getSource()
setSource(java.lang.String)public void setSource(java.lang.String src)
src - the default image file name and pathgetSource(),
ImageViewpublic void setText(java.lang.String txt)
setText in interface com.sas.lang.StringDataInterfacesetText in class BaseButtontxt - the text displayedBaseButton.getText()public void setVerticalTextAlignment(int vAlign)
setVerticalTextAlignment in class BaseButtonvAlign - protected int value derived from com.sas.geometry.OrientaionsBaseButton.setVerticalTextAlignment(int),
Orientations
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||