All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.visuals
Class PushButton

    com.sas.visuals.PushButton

All Implemented Interfaces:
  ActionSource, CompositeInterface, ContainerInterface, com.sas.awt.print.PrintableInterface, VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, ComponentInterface, DesignTimeDropTargetInterface, com.sas.lang.StringDataInterface, LinkPropertiesInterface, ModelInterface, com.sas.PublicClonable, ValidatorInterface, ViewInterface, Alignment, MultipleValueEventSourceInterface, ResizeToFitInterface, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

Direct Known Subclasses:
  ArrowButton, ToolbarButton

    public class PushButton

implements com.sas.PublicClonable

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");

- Uses `IconInterface` objects to paint images ( `ImageView` is an IconInterface object ).
- A source property is provided but only sets the `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`.
- The `defaultIcon` must be set before any of the icons will be displayed.

See Also:
  `BaseButton`, `ToggleButton`, Serialized Form

Field 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 class com.sas.visuals.BaseButton
`actionPerformed, addActionListener, addItemListener, addNotify, buttonModelDisabled, buttonModelRollover, buttonModelSelected, computePreferredSize, detachModel, focusGained, focusLost, getActionCommand, getButtonListener, getButtonModel, getContentSize, getDefaultIcon, getDisabledIcon, getDisplayTransform, getFocusGap, getHorizontalAlignment, getHorizontalTextAlignment, getIconTextGap, getInsets, getItem, getKeyAccelerator, getPressedIcon, getRequiredInterfaces, getRolloverIcon, getSelectedIcon, getSelectedObjects, getText, getTextPosition, getVerticalAlignment, getVerticalTextAlignment, isBorderPainted, isFocusPainted, isFocusTraversable, isResizeToFit, isSelected, itemStateChanged, processActionEvent, processEvent, processItemEvent, propertyChange, refresh, refreshItem, removeActionListener, removeItemListener, resizeToFit, setActionCommand, setBorderPainted, setBounds, setButtonListener, setButtonModel, setDefaultIcon, setDefaultValues, setDisabledIcon, setDisplayTransform, setEnabled, setFocusGap, setFocusPainted, setHorizontalAlignment, setIconTextGap, setInsets, setItem, setKeyAccelerator, setPressedIcon, setResizeToFit, setRolloverIcon, setSelected, setSelectedIcon, setTextPosition, setVerticalAlignment`

Methods inherited from class com.sas.awt.ContainerContainerComponent
`dragEnter, dragLeave, dragOver, drop, getContainerInterfaceSupportInfo, getErrorHandler, getValidator, isIDEDnDDropBarrier, isIDEDnDDropTarget, isValid, removeNotify, setContainerInterfaceSupportInfo, setErrorHandler, setIDEDnDDropBarrier, setIDEDnDDropTarget, setInsets, setValidator, superAddNotify, superGetInsets, superRemoveNotify, superSetDefaultValues`

Methods inherited from class com.sas.awt.ContainerVisualComponent
`addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getModelInterface, getPageBounds, getPreferredSize, getPrePainter, getPrintOptionsPanel, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initialize, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, pageExists, print, printFinalize, printInitialize, queryLinks, queryLinks, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setComponentDescription, setComponentSupportInfo, 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`

Methods inherited from interface com.sas.awt.ContainerInterface
`getComponents, getLayout, invalidate, setLayout, validate`

Methods inherited from interface com.sas.awt.VisualInterface
`getBackgroundColor, getBorder, getFont, getForegroundColor, getHeight, getHorizontalPosition, getPreferredSize, getPrePainter, getVerticalPosition, getVisualInterfaceSupportInfo, getWidth, isEnabled, isFocus, isTransparent, isVisible, setBackgroundColor, setBorder, setFocus, setForegroundColor, setHeight, setHorizontalPosition, setPreferredSize, setPrePainter, setTransparent, setVerticalPosition, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate`

Field Detail

### label

    protected LabelView label

  A `LabelView` object used in the PushButton to display the text.

### contentShift

    protected java.awt.Point contentShift

  `Point` value that specifies the amount the PushButton shifts when pressed.

### RB_KEY

    public static java.lang.String RB_KEY

Constructor Detail

### PushButton

    public PushButton()

  Default constructor.

### PushButton

    public PushButton(java.lang.String txt)

  Constructor that sets the text to be displayed.

  Parameters:
    `txt` - the text to display on the PushButton

### PushButton

    public PushButton(com.sas.visuals.IconInterface defaultImg)

  Constructor that sets the default image to be displayed.

  Parameters:
    `defaultImg` - the default image to display on the PushButton

### PushButton

    public PushButton(java.lang.String txt,
                      com.sas.visuals.IconInterface defaultImg)

  Constructor that sets both the default image and the text to be displayed.

  Parameters:
    `txt` - the text to display on the PushButton
    `defaultImg` - the default image to display on the PushButton

Method Detail

### getDefaultHeight

    public static int getDefaultHeight()

  Returns the default height of this PushButton in pixels

  Returns:
    pixel value of the default height
  See Also:
    `setDefaultHeight(int)`

### getDefaultWidth

    public static int getDefaultWidth()

  Returns the default width of this PushButton in pixels

  Returns:
    pixel value of default width
  See Also:
    `setDefaultWidth(int)`

### setDefaultHeight

    public static void setDefaultHeight(int newHeight)

  Sets the default height of this PushButton in pixels

  Parameters:
    `newHeight` - the desired default height in pixels
  See Also:
    `getDefaultHeight()`

### setDefaultWidth

    public static void setDefaultWidth(int newWidth)

  Sets the default width of the PushButton

  Parameters:
    `newWidth` - the desired default width in pixels
  See Also:
    `setDefaultWidth(int)`

### getExtendedBeanInfo

    public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

  Returns information used by the `com.sas.beans.Introspector` to augment the automatically introspected information about this PushButton.

  Returns:
    the ExtendedBeanInfo for this class

### buttonModelArmed

    protected void buttonModelArmed(ButtonModelInterface btnModel)

  Handles change in buttonModel armed 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 armed property changes.

  Overrides:
    `buttonModelArmed` in class `BaseButton`
  Parameters:
    `btnModel` - the buttonModel that changed.

### buttonModelPressed

    protected void buttonModelPressed(ButtonModelInterface btnModel)

  Handles change in buttonModel `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.

  Overrides:
    `buttonModelPressed` in class `BaseButton`
  Parameters:
    `btnModel` - the buttonModel that changed.

### contentShift

    public java.awt.Point contentShift()

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Creates a clone of this PushButton.

  Specified by:
    `clone` in interface `com.sas.PublicClonable`
  Overrides:
    `clone` in class `BaseButton`
  Returns:
    a clone of this PushButton
  Throws:
    `java.lang.CloneNotSupportedException` - if the clone creation fails

### getMinimumSize

    public java.awt.Dimension getMinimumSize()

  Returns the minimum size of the PushButton.

  Specified by:
    `getMinimumSize` in interface `VisualInterface`
  Overrides:
    `getMinimumSize` in class `ContainerVisualComponent`
  Returns:
    the minimum size of based on the size of the content of PushButton
  See Also:
    `VisualInterface.getMinimumSize()`

### paint

    public void paint(java.awt.Graphics g)

  Paint the PushButton in its current state based on the buttonModel.

  Overrides:
    `paint` in class `ContainerVisualComponent`
  Parameters:
    `g` - the Graphics context.
  See Also:
    `VisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)`

### paintBackground

    protected void paintBackground(java.awt.Graphics g)

  Paint the background on the PushButton.

  Parameters:
    `g` - the Graphics context

### paintFocus

    protected void paintFocus(java.awt.Graphics g)

  Paint the focus rectangle on the PushButton.

  Parameters:
    `g` - the Graphics context

### getContentShift

    public java.awt.Point getContentShift()

  Get the amount the content is shifted when the PushButton is pressed while armed.

  Returns:
    the point to translate the contents postion by when the button is pressed or selected.
  See Also:
    `setContentShift(java.awt.Point)`

### setContentShift

    public void setContentShift(java.awt.Point pt)

  Sets the amount the content is shifted when the PushButton is pressed while armed. The default value is (1,1). This is not used if the `pressedIcon` has been set.

  Parameters:
    `pt` - the point to translate the contents postion by when the button is pressed or selected.
  See Also:
    `getContentShift()`

### setFont

    public void setFont(java.awt.Font f)

  Sets the font of the text on the PushButton.

  Specified by:
    `setFont` in interface `VisualInterface`
  Overrides:
    `setFont` in class `BaseButton`
  Parameters:
    `f` - the font of the PushButton text
  See Also:
    `VisualInterface.setFont(java.awt.Font)`

### setHorizontalTextAlignment

    public void setHorizontalTextAlignment(int hAlign)

  Sets the horizontal alignment of the text of the PushButton. The alignment can be set to: LEFT, CENTER, or RIGHT

  Overrides:
    `setHorizontalTextAlignment` in class `BaseButton`
  Parameters:
    `hAlign` - protected int value derived from `com.sas.geometry.Orientaions`
  See Also:
    `BaseButton.setHorizontalTextAlignment(int)`, `Orientations`

### setVerticalTextAlignment

    public void setVerticalTextAlignment(int vAlign)

  Set the vertical alignment of the text displayed on the button. The alignment can be TOP, CENTER, or BOTTOM

  Overrides:
    `setVerticalTextAlignment` in class `BaseButton`
  Parameters:
    `vAlign` - protected int value derived from `com.sas.geometry.Orientaions`
  See Also:
    `BaseButton.setVerticalTextAlignment(int)`, `Orientations`

### setText

    public void setText(java.lang.String txt)

  Set the text to be displayed on the PushButton.

  Specified by:
    `setText` in interface `com.sas.lang.StringDataInterface`
  Overrides:
    `setText` in class `BaseButton`
  Parameters:
    `txt` - the text displayed
  See Also:
    `BaseButton.getText()`

### getSource

    public java.lang.String getSource()

  Returns the source of the image displayed as the default image.

  Returns:
    string valid source path only if the defaultIcon is an `ImageView`
  See Also:
    `setSource(java.lang.String)`

### setSource

    public void setSource(java.lang.String src)

  Sets the source of the image displayed as the default image. This method creates an `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.

  Parameters:
    `src` - the default image full valid path name
  See Also:
    `getSource()`, `ImageView`

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.