|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.visuals.PushButton
public class PushButton
PushButton is a class that creates a button where images and text, or both can be displayed.
When the button is pressed an ActionEvent is sent to any listeners.
The text and images can be aligned horizontally and vertically.
Notes:
Sample code:
PushButton pushButton1 = new PushButton();
IconInterface defaultIcon = new ImageView("d:/someImage.gif");
pushButton1.setDefaultIcon( defaultIcon );
pushButton1.setText("Button");
IconInterface
objects to paint images ( ImageView
is an IconInterface object ).
defaultIcon
by creating an ImageView
and setting the source
property on the ImageView. If the defaultIcon
is not an
ImageView
and is not null, then setting the source
will not change the defaultIcon
.
defaultIcon
must be set before any of the icons will be displayed.
BaseButton
,
ToggleButton
,
Serialized FormField Summary | |
---|---|
protected java.awt.Point |
contentShift
Point value that specifies the amount the PushButton shifts when pressed. |
protected LabelView |
label
A LabelView object used in the PushButton to display the text. |
static java.lang.String |
RB_KEY
|
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 | |
---|---|
PushButton()
Default constructor. |
|
PushButton(com.sas.visuals.IconInterface defaultImg)
Constructor that sets the default image to be displayed. |
|
PushButton(java.lang.String txt)
Constructor that sets the text to be displayed. |
|
PushButton(java.lang.String txt,
com.sas.visuals.IconInterface defaultImg)
Constructor that sets both the default image and the text to be displayed. |
Method Summary | |
---|---|
protected void |
buttonModelArmed(ButtonModelInterface btnModel)
Handles change in buttonModel armed property. |
protected void |
buttonModelPressed(ButtonModelInterface btnModel)
Handles change in buttonModel pressed property. |
java.lang.Object |
clone()
Creates a clone of this PushButton. |
java.awt.Point |
contentShift()
|
java.awt.Point |
getContentShift()
Get the amount the content is shifted when the PushButton is pressed while armed. |
static int |
getDefaultHeight()
Returns the default height of this PushButton in pixels |
static int |
getDefaultWidth()
Returns the default width of this PushButton in pixels |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this PushButton. |
java.awt.Dimension |
getMinimumSize()
Returns the minimum size of the PushButton. |
java.lang.String |
getSource()
Returns the source of the image displayed as the default image. |
void |
paint(java.awt.Graphics g)
Paint the PushButton in its current state based on the buttonModel. |
protected void |
paintBackground(java.awt.Graphics g)
Paint the background on the PushButton. |
protected void |
paintFocus(java.awt.Graphics g)
Paint the focus rectangle on the PushButton. |
void |
setContentShift(java.awt.Point pt)
Sets the amount the content is shifted when the PushButton is pressed while armed. |
static void |
setDefaultHeight(int newHeight)
Sets the default height of this PushButton in pixels |
static void |
setDefaultWidth(int newWidth)
Sets the default width of the PushButton |
void |
setFont(java.awt.Font f)
Sets the font of the text on the PushButton. |
void |
setHorizontalTextAlignment(int hAlign)
Sets the horizontal alignment of the text of the PushButton. |
void |
setSource(java.lang.String src)
Sets the source of the image displayed as the default image. |
void |
setText(java.lang.String txt)
Set the text to be displayed on the PushButton. |
void |
setVerticalTextAlignment(int vAlign)
Set the vertical alignment of the text displayed on the button. |
Methods inherited from interface com.sas.awt.ContainerInterface |
---|
getComponents, getLayout, invalidate, setLayout, validate |
Field Detail |
---|
protected LabelView label
LabelView
object used in the PushButton to display the text.
protected java.awt.Point contentShift
Point
value that specifies the amount the PushButton shifts when pressed.
public static java.lang.String RB_KEY
Constructor Detail |
---|
public PushButton()
public PushButton(java.lang.String txt)
txt
- the text to display on the PushButtonpublic PushButton(com.sas.visuals.IconInterface defaultImg)
defaultImg
- the default image to display on the PushButtonpublic PushButton(java.lang.String txt, com.sas.visuals.IconInterface defaultImg)
txt
- the text to display on the PushButtondefaultImg
- the default image to display on the PushButtonMethod 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 pixelssetDefaultWidth(int)
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector
to
augment the automatically introspected information about this PushButton.
protected void buttonModelArmed(ButtonModelInterface btnModel)
buttonModelArmed
in class BaseButton
btnModel
- the buttonModel that changed.protected void buttonModelPressed(ButtonModelInterface btnModel)
pressed
property.
Changes the light source of the border based on the buttonModel.
Repaint the button if buttonModel is not disabled.
Override to change the behavior when the model pressed property changes.
buttonModelPressed
in class BaseButton
btnModel
- the buttonModel that changed.public java.awt.Point contentShift()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface com.sas.PublicClonable
clone
in class BaseButton
java.lang.CloneNotSupportedException
- if the clone creation failspublic java.awt.Dimension getMinimumSize()
getMinimumSize
in interface VisualInterface
getMinimumSize
in class ContainerVisualComponent
VisualInterface.getMinimumSize()
public void paint(java.awt.Graphics g)
paint
in class ContainerVisualComponent
g
- the Graphics context.VisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)
protected void paintBackground(java.awt.Graphics g)
g
- the Graphics contextprotected void paintFocus(java.awt.Graphics g)
g
- the Graphics contextpublic java.awt.Point getContentShift()
setContentShift(java.awt.Point)
public void setContentShift(java.awt.Point pt)
pressedIcon
has been set.
pt
- the point to translate the contents postion by when
the button is pressed or selected.getContentShift()
public void setFont(java.awt.Font f)
setFont
in interface VisualInterface
setFont
in class BaseButton
f
- the font of the PushButton textVisualInterface.setFont(java.awt.Font)
public void setHorizontalTextAlignment(int hAlign)
setHorizontalTextAlignment
in class BaseButton
hAlign
- protected int value derived from com.sas.geometry.Orientaions
BaseButton.setHorizontalTextAlignment(int)
,
Orientations
public void setVerticalTextAlignment(int vAlign)
setVerticalTextAlignment
in class BaseButton
vAlign
- protected int value derived from com.sas.geometry.Orientaions
BaseButton.setVerticalTextAlignment(int)
,
Orientations
public void setText(java.lang.String txt)
setText
in interface com.sas.lang.StringDataInterface
setText
in class BaseButton
txt
- the text displayedBaseButton.getText()
public java.lang.String getSource()
ImageView
setSource(java.lang.String)
public void setSource(java.lang.String src)
ImageView
and sets it as the
defaultIcon if the defaultIcon is null. If the defaultIcon
is an ImageView
this method sets the source of the ImageView
to the specified path.
src
- the default image full valid path namegetSource()
,
ImageView
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |