org.scopemvc.view.swing
Class SActionListener

java.lang.Object
  |
  +--org.scopemvc.view.swing.SActionListener
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class SActionListener
extends java.lang.Object
implements java.awt.event.ActionListener

Connects component action event to a method in a model.

Let's have button Save and method void saveData() in model object, which should be called, when button is pressed. The connection can be done in following way:

     JButton button = new JButton("Save");
     SActionListener action = new SActionListener();
     action.setModelActionString("saveData");
     button.addActionListener(action);
     ...
     action.setBoundModel(myModel);
 

Version:
$Revision: 1.5 $ $Date: 2002/09/05 15:41:49 $
Author:
Daniel Michalik

Constructor Summary
SActionListener()
          Creates new SActionListener
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ev)
          Called by component to notify, that user performed action on the component.
 java.lang.Object getBoundModel()
          Gets the bound model
 void setBoundModel(java.lang.Object inModel)
          Sets model object on which the method will be called.
 void setModelActionString(java.lang.String s)
          Sets name of method to call on model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SActionListener

public SActionListener()
Creates new SActionListener

Method Detail

getBoundModel

public final java.lang.Object getBoundModel()
Gets the bound model

Returns:
The boundModel value

setModelActionString

public final void setModelActionString(java.lang.String s)
Sets name of method to call on model. The name is case sensitive.

Parameters:
s - The new modelActionString value

setBoundModel

public final void setBoundModel(java.lang.Object inModel)
Sets model object on which the method will be called.

Parameters:
inModel - The new boundModel value

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ev)
Called by component to notify, that user performed action on the component. Specified method is called on the model.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
ev - TODO: Describe the Parameter
Throws:
java.lang.IllegalStateException - if model action (method) is not set
See Also:
setModelActionString(java.lang.String)


Copyright © 2000-2002 The Scope Team. All Rights Reserved.