com.sas.visuals
Class DefaultButtonListener

com.sas.visuals.DefaultButtonListener
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.ViewInterface, ButtonListenerInterface, MultipleValueEventSourceInterface, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.util.EventListener

public class DefaultButtonListener
implements ButtonListenerInterface

DefaultButtonListener is an implementation of the ButtonListenerInterface used to listen for user events on a button component and change the state of the ButtonModelInterface property. The button component will listen on the ButtonModelInterface object and will forward the state changes of the ButtonModelInterface to the user.

See Also:
DefaultButtonModel, BaseButton, ButtonModelInterface, Serialized Form

Field Summary
protected  ButtonModelInterface model
           
 
Constructor Summary
DefaultButtonListener()
          Default Constructor
DefaultButtonListener(ButtonModelInterface btnModel)
          Constructor that sets the buttonModel to change the state of based on the user events listened for.
 
Method Summary
 ButtonModelInterface getButtonModel()
          Get the ButtonModelInterface object associated with this ButtonListenerInterface.
protected  boolean isActivationKey(java.awt.event.KeyEvent keyEvent)
          Method to determine if a key should activate the model.
 void keyPressed(java.awt.event.KeyEvent evt)
          Method invoked when a key is pressed by the user while the component listened on has focus.
 void keyReleased(java.awt.event.KeyEvent evt)
          Method invoked when a key is released by the user while the component listened on has focus.
 void keyTyped(java.awt.event.KeyEvent evt)
          Method invoked when a key is typed by the user while the component listened on has focus.
 void mouseClicked(java.awt.event.MouseEvent evt)
          Method invoked when the mouse is clicked.
 void mouseDragged(java.awt.event.MouseEvent evt)
          Method invoked when the mouse is dragged.
 void mouseEntered(java.awt.event.MouseEvent evt)
          Method invoked when the mouse enters the button component area.
 void mouseExited(java.awt.event.MouseEvent evt)
          Method invoked when the mouse exits the button component area.
 void mouseMoved(java.awt.event.MouseEvent evt)
          Method invoked when the mouse is moved.
 void mousePressed(java.awt.event.MouseEvent evt)
          Method invoked when the mouse is pressed.
 void mouseReleased(java.awt.event.MouseEvent evt)
          Method invoked when the mouse is released.
 void setButtonModel(ButtonModelInterface btnModel)
          Set the ButtonModelInterface object associated with this ButtonListenerInterface The buttonModel state will be changed based on the user events received by this buttonListener.
 

Field Detail

model

protected ButtonModelInterface model
Constructor Detail

DefaultButtonListener

public DefaultButtonListener()
Default Constructor


DefaultButtonListener

public DefaultButtonListener(ButtonModelInterface btnModel)
Constructor that sets the buttonModel to change the state of based on the user events listened for.

Method Detail

getButtonModel

public ButtonModelInterface getButtonModel()
Get the ButtonModelInterface object associated with this ButtonListenerInterface. The buttonModel state will be changed based on the user events received by this buttonListener.

Specified by:
getButtonModel in interface ButtonListenerInterface

setButtonModel

public void setButtonModel(ButtonModelInterface btnModel)
Set the ButtonModelInterface object associated with this ButtonListenerInterface The buttonModel state will be changed based on the user events received by this buttonListener.

Specified by:
setButtonModel in interface ButtonListenerInterface

isActivationKey

protected boolean isActivationKey(java.awt.event.KeyEvent keyEvent)
Method to determine if a key should activate the model. Currently only checks the model's keyAccelerator, VK_SPACE, and VK_ENTER. This should be overridden if another behavior is needed.

Parameters:
keyCode - the KeyEvent virtual key code.

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Method invoked when a key is pressed by the user while the component listened on has focus. Causes the buttonModel armed and pressed to be set to true.

Specified by:
keyPressed in interface java.awt.event.KeyListener
See Also:
KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Method invoked when a key is released by the user while the component listened on has focus. This sets the buttonModel pressed to false.

Specified by:
keyReleased in interface java.awt.event.KeyListener
See Also:
KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Method invoked when a key is typed by the user while the component listened on has focus. DOES NOTHING in this implementation.

Specified by:
keyTyped in interface java.awt.event.KeyListener
See Also:
KeyListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Method invoked when the mouse is moved. DOES NOTHING in this implementation.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Method invoked when the mouse is dragged. This sets the buttonModel rollover and armed to true if the mouse is dragged over the button component and false otherwise. DOES NOTHING in this implementation.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Method invoked when the mouse is clicked. DOES NOTHING in this implementation.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Method invoked when the mouse is pressed. If the event is from a double click, only the first MouseEvent will be used. This keeps multiple ActionEvents from being fired. This sets the buttonModel pressed and armed to true.

Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Method invoked when the mouse is released. This sets the buttonModel pressed to false.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Method invoked when the mouse enters the button component area. This sets the buttonModel rollover to true.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Method invoked when the mouse exits the button component area. This sets the buttonModel rollover to false.

Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener



Copyright © 2009 SAS Institute Inc. All Rights Reserved.