com.sibvisions.rad.ui.swing.impl.component
Class SwingAbstractButton<C extends AbstractButton>

java.lang.Object
  extended by com.sibvisions.rad.ui.awt.impl.AwtResource<C>
      extended by com.sibvisions.rad.ui.awt.impl.AwtComponent<C>
          extended by com.sibvisions.rad.ui.awt.impl.AwtContainer<C>
              extended by com.sibvisions.rad.ui.swing.impl.SwingComponent<C>
                  extended by com.sibvisions.rad.ui.swing.impl.component.SwingAbstractLabeledIconButton<C>
                      extended by com.sibvisions.rad.ui.swing.impl.component.SwingAbstractButton<C>
Type Parameters:
C - instance of AbstractButton.
All Implemented Interfaces:
ActionListener, ComponentListener, FocusListener, KeyListener, MouseListener, EventListener, IActionComponent, IButton, IIcon, ILabel, ILabeledIcon, IAlignmentConstants, IComponent, IContainer, IResource, INamedObject
Direct Known Subclasses:
SwingButton, SwingMenuItem, SwingToggleButton

public abstract class SwingAbstractButton<C extends AbstractButton>
extends SwingAbstractLabeledIconButton<C>
implements IButton, ActionListener

The SwingButton is the IButton implementation for swing.

See Also:
AbstractButton, IButton

Field Summary
protected  IImage imgOver
          the mouse over image.
protected  IImage imgPressed
          the mouse pressed image.
 
Fields inherited from class com.sibvisions.rad.ui.swing.impl.component.SwingAbstractLabeledIconButton
image
 
Fields inherited from class com.sibvisions.rad.ui.awt.impl.AwtComponent
bComponentListener, bFocusListener, bKeyListener, bMouseListener, eventComponentMoved, eventComponentResized, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, eventSource, factory, parent
 
Fields inherited from class com.sibvisions.rad.ui.awt.impl.AwtResource
resource
 
Fields inherited from interface javax.rad.ui.IAlignmentConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_STRETCH, ALIGN_TOP
 
Constructor Summary
SwingAbstractButton(C pAbstractButton)
          Creates a new instance of SwingAbstractButton.
 
Method Summary
 void actionPerformed(ActionEvent pActionEvent)
          
 ActionHandler eventAction()
          The EventHandler for the action event.
 Key getAccelerator()
          Returns the Key which serves as an accelerator for the button.
 String getActionCommand()
          Returns the command name of the action event fired by this action component.
 int getHorizontalTextPosition()
          Returns the horizontal position of the text relative to the icon.
 int getImageTextGap()
          Returns the amount of space between the text and the icon displayed in this button.
 IInsets getMargins()
          Returns the margin between the component's border and the text.
 IImage getMouseOverImage()
          Gets the image for the button when the mouse is over.
 IImage getPressedImage()
          Gets the image for the button when the button is pressed.
 int getVerticalTextPosition()
          Returns the vertical position of the text relative to the icon.
protected  void initDummyImage()
          Initializes a dummy image.
 boolean isBorderOnMouseEntered()
          Gets, if the border should only be shown on mouse entered.
 boolean isBorderPainted()
          Gets whether the border will be painted.
 boolean isDefaultButton()
          Gets the value of the defaultButton property, which if true means that this button is the current default button.
 void setAccelerator(Key pKey)
          Sets the key combination which invokes the component's action listeners without selecting.
 void setActionCommand(String pActionCommand)
          Sets the command name for the action event fired by this action component.
 void setBorderOnMouseEntered(boolean pBorderOnMouseEntered)
          Sets, if the border should only be shown on mouse entered.
 void setBorderPainted(boolean pBorderPainted)
          Sets whether the border will be painted.
 void setDefaultButton(boolean pDefault)
          Sets the defaultButton property.
 void setHorizontalTextPosition(int pHorizontalPosition)
          Sets the horizontal position of the text relative to the icon.
 void setImage(IImage pImage)
          Sets the default image.
 void setImageTextGap(int pImageTextGap)
          If both the icon and text properties are set, this property defines the space between them.
 void setMargins(IInsets pMargins)
          Sets space for margin between the button's border and the text.
 void setMouseOverImage(IImage pImage)
          Sets the image for the button when the mouse is over.
 void setPressedImage(IImage pImage)
          Sets the image for the button when the button is pressed.
 void setVerticalTextPosition(int pVerticalPosition)
          Sets the vertical position of the text relative to the icon.
 
Methods inherited from class com.sibvisions.rad.ui.swing.impl.component.SwingAbstractLabeledIconButton
getImage, getText, isPreserveAspectRatio, setBackground, setHorizontalAlignment, setPreserveAspectRatio, setText, setVerticalAlignment
 
Methods inherited from class com.sibvisions.rad.ui.swing.impl.SwingComponent
capture, getToolTipText, setTabIndex, setToolTipText
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtContainer
add, add, add, add, addIntern, checkAdd, getComponent, getComponentCount, getLayout, indexOf, remove, remove, removeAll, removeIntern, setLayout, setLayoutIntern
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtComponent
addComponentListener, addFocusListener, addKeyListener, addMouseListener, componentHidden, componentMoved, componentResized, componentShown, createImage, createMouseEvent, equals, eventComponentMoved, eventComponentResized, eventFocusGained, eventFocusLost, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, focusGained, focusLost, getBackground, getBounds, getCursor, getEventSource, getFactory, getFont, getForeground, getHorizontalAlignment, getLocation, getLocationRelativeTo, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getStyle, getTabIndex, getVerticalAlignment, hashCode, invalidateLayout, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, requestFocus, setBounds, setCursor, setEnabled, setEventSource, setFactory, setFocusable, setFont, setForeground, setLocation, setLocationRelativeTo, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setStyle, setVisible, validate
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtResource
getResource, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.rad.ui.component.IIcon
getImage, isPreserveAspectRatio, setPreserveAspectRatio
 
Methods inherited from interface javax.rad.ui.component.ILabel
getText, setText
 
Methods inherited from interface javax.rad.ui.IComponent
capture, eventComponentMoved, eventComponentResized, eventFocusGained, eventFocusLost, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getEventSource, getFactory, getFont, getForeground, getLocation, getLocationRelativeTo, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getStyle, getTabIndex, getToolTipText, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, requestFocus, setBackground, setBounds, setCursor, setEnabled, setEventSource, setFocusable, setFont, setForeground, setLocation, setLocationRelativeTo, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setStyle, setTabIndex, setToolTipText, setVisible
 
Methods inherited from interface javax.rad.ui.IResource
getResource
 
Methods inherited from interface javax.rad.ui.IAlignmentConstants
getHorizontalAlignment, getVerticalAlignment, setHorizontalAlignment, setVerticalAlignment
 

Field Detail

imgOver

protected IImage imgOver
the mouse over image.


imgPressed

protected IImage imgPressed
the mouse pressed image.

Constructor Detail

SwingAbstractButton

public SwingAbstractButton(C pAbstractButton)
Creates a new instance of SwingAbstractButton.

Parameters:
pAbstractButton - the instance of AbstractButton.
Method Detail

setVerticalTextPosition

public void setVerticalTextPosition(int pVerticalPosition)
Sets the vertical position of the text relative to the icon.

Specified by:
setVerticalTextPosition in interface IButton
Parameters:
pVerticalPosition - one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.TOP
  • IAlignmentConstants.BOTTOM

getVerticalTextPosition

public int getVerticalTextPosition()
Returns the vertical position of the text relative to the icon.

Specified by:
getVerticalTextPosition in interface IButton
Returns:
one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.TOP
  • IAlignmentConstants.BOTTOM

setHorizontalTextPosition

public void setHorizontalTextPosition(int pHorizontalPosition)
Sets the horizontal position of the text relative to the icon.

Specified by:
setHorizontalTextPosition in interface IButton
Parameters:
pHorizontalPosition - one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.LEFT
  • IAlignmentConstants.RIGHT

getHorizontalTextPosition

public int getHorizontalTextPosition()
Returns the horizontal position of the text relative to the icon.

Specified by:
getHorizontalTextPosition in interface IButton
Returns:
one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.LEFT
  • IAlignmentConstants.RIGHT

getImageTextGap

public int getImageTextGap()
Returns the amount of space between the text and the icon displayed in this button.

Specified by:
getImageTextGap in interface IButton
Returns:
an int equal to the number of pixels between the text and the icon.
See Also:
IButton.setImageTextGap(int)

setImageTextGap

public void setImageTextGap(int pImageTextGap)
If both the icon and text properties are set, this property defines the space between them.

The default value of this property is 4 pixels.

This is a JavaBeans bound property.

Specified by:
setImageTextGap in interface IButton
Parameters:
pImageTextGap - the image gap
See Also:
IButton.getImageTextGap()

isBorderOnMouseEntered

public boolean isBorderOnMouseEntered()
Gets, if the border should only be shown on mouse entered.

Specified by:
isBorderOnMouseEntered in interface IButton
Returns:
true, if the border should only be shown on mouse entered.

setBorderOnMouseEntered

public void setBorderOnMouseEntered(boolean pBorderOnMouseEntered)
Sets, if the border should only be shown on mouse entered.

Specified by:
setBorderOnMouseEntered in interface IButton
Parameters:
pBorderOnMouseEntered - true, if the border should only be shown on mouse entered.

setAccelerator

public void setAccelerator(Key pKey)
Sets the key combination which invokes the component's action listeners without selecting. It is the UI's responsibility to install the correct action.

Specified by:
setAccelerator in interface IActionComponent
Parameters:
pKey - the Key which will serve as an accelerator

getAccelerator

public Key getAccelerator()
Returns the Key which serves as an accelerator for the button.

Specified by:
getAccelerator in interface IActionComponent
Returns:
a Key object identifying the accelerator key

setBorderPainted

public void setBorderPainted(boolean pBorderPainted)
Sets whether the border will be painted. If true, the border will be painted. The default value is that the border will be painted.

Specified by:
setBorderPainted in interface IButton
Parameters:
pBorderPainted - true to paint the border, otherwise false

isBorderPainted

public boolean isBorderPainted()
Gets whether the border will be painted.

Specified by:
isBorderPainted in interface IButton
Returns:
true when the border will be painted, otherwise false

setMouseOverImage

public void setMouseOverImage(IImage pImage)
Sets the image for the button when the mouse is over.

Specified by:
setMouseOverImage in interface IButton
Parameters:
pImage - the mouse over image

getMouseOverImage

public IImage getMouseOverImage()
Gets the image for the button when the mouse is over.

Specified by:
getMouseOverImage in interface IButton
Returns:
the mouse over image

setPressedImage

public void setPressedImage(IImage pImage)
Sets the image for the button when the button is pressed.

Specified by:
setPressedImage in interface IButton
Parameters:
pImage - the mouse pressed image

getPressedImage

public IImage getPressedImage()
Gets the image for the button when the button is pressed.

Specified by:
getPressedImage in interface IButton
Returns:
the mouse pressed image

setDefaultButton

public void setDefaultButton(boolean pDefault)
Sets the defaultButton property. The default button is the button which will be activated when a UI-defined activation event (typically the Enter key) occurs, regardless of whether or not the button has keyboard focus (unless there is another component within which consumes the activation event) For default activation to work, the button must be enabled.

Specified by:
setDefaultButton in interface IButton
Parameters:
pDefault - true to set this button as default button, otherwise false
See Also:
IButton.isDefaultButton()

isDefaultButton

public boolean isDefaultButton()
Gets the value of the defaultButton property, which if true means that this button is the current default button.

Specified by:
isDefaultButton in interface IButton
Returns:
true if this button is defined as default button, otherwise false
See Also:
IButton.setDefaultButton(boolean)

getActionCommand

public String getActionCommand()
Returns the command name of the action event fired by this action component.

Specified by:
getActionCommand in interface IActionComponent
Returns:
the action command.

setActionCommand

public void setActionCommand(String pActionCommand)
Sets the command name for the action event fired by this action component.

Specified by:
setActionCommand in interface IActionComponent
Parameters:
pActionCommand - a string used to set the action command.
See Also:
ActionEvent

eventAction

public ActionHandler eventAction()
The EventHandler for the action event.

Specified by:
eventAction in interface IActionComponent
Returns:
the EventHandler for the action event.

setMargins

public void setMargins(IInsets pMargins)
Sets space for margin between the button's border and the text. Setting to null will cause the action component to use the default margin.

Specified by:
setMargins in interface IActionComponent
Parameters:
pMargins - the space between the border and the test

getMargins

public IInsets getMargins()
Returns the margin between the component's border and the text.

Specified by:
getMargins in interface IActionComponent
Returns:
an IInsets object specifying the margin between the component's border and the text
See Also:
IActionComponent.setMargins(IInsets)

actionPerformed

public void actionPerformed(ActionEvent pActionEvent)

Specified by:
actionPerformed in interface ActionListener

setImage

public void setImage(IImage pImage)
Sets the default image.

Specified by:
setImage in interface IIcon
Overrides:
setImage in class SwingAbstractLabeledIconButton<C extends AbstractButton>
Parameters:
pImage - the image
See Also:
IIcon.getImage()

initDummyImage

protected void initDummyImage()
Initializes a dummy image.



Copyright © 2009 SIB Visions GmbH. All Rights Reserved.