Horus Doc || Java GUI Reference || Doxygen's quick Index  

JavaFuncDialog Class Reference

A dialog box for calling a member function of an object (target) with user specified parameters. More...

List of all members.

Public Methods

 JavaFuncDialog (Object target, CallableMethod targetMethod)
 Constructor for calling a target member function directly from a modeless (non-modal) dialog box. More...

 JavaFuncDialog (Object target, CallableMethod targetMethod, Object user, String userMethodName, boolean modal)
 Constructor for calling a target member function via a user. More...

void actionPerformed (ActionEvent e)
 Implementation of ActionListener. More...


Detailed Description

A dialog box for calling a member function of an object (target) with user specified parameters.

The description of the member function is given by the CallableMethod. Optionally, a user Object may be specified.

If (user == null) the method on the target is invoked when the OK button in the dialog box is pressed. If (user != null) the target method is not invoked directly. Instead the userMethod of the user object is called with three parameters: the target Object, the CallableMethod of the target object, and the argument values. The user object then has the responsibility of invoking the target method.


Constructor & Destructor Documentation

JavaFuncDialog::JavaFuncDialog Object    target,
CallableMethod    targetMethod
[inline]
 

Constructor for calling a target member function directly from a modeless (non-modal) dialog box.

00043 {
00044     super(new JFrame(), "JavaFuncDialog", true);
00045     doInit(target, targetMethod, null, "");
00046 }

JavaFuncDialog::JavaFuncDialog Object    target,
CallableMethod    targetMethod,
Object    user,
String    userMethodName,
boolean    modal
[inline]
 

Constructor for calling a target member function via a user.

00053 {
00054     super(new JFrame(), "JavaFuncDialog", modal);
00055     doInit(target, targetMethod, user, userMethodName);
00056 }


Member Function Documentation

void JavaFuncDialog::actionPerformed ActionEvent    e [inline]
 

Implementation of ActionListener.

00062 {
00063 
00064     if (e.getSource() == _cancelButton) {
00065         // handleFuncDialogCancel();
00066     } else {
00067         int nArgs = _method.getNumArgs();
00068         Object[] argVals = new Object[nArgs];
00069         int i;
00070         for (i=0 ; i<nArgs ; i++) {
00071             argVals[i] = _argChoice[i].getSelectedVal();
00072         }
00073         Cursor oldCursor = getCursor();
00074         Method method = null;
00075         try {
00076             if (_user == null) {
00077                 _method.invoke(_target, argVals);
00078             } else {
00079                 Class[] userArgClass = new Class[3];
00080                 userArgClass[0] = Object.class;
00081                 userArgClass[1] = CallableMethod.class;
00082                 userArgClass[2] = argVals.getClass();
00083                 method = _user.getClass().getMethod(_userMethodName, userArgClass);
00084                 Object[] userArgsVals = new Object[3];
00085                 userArgsVals[0] = _target;
00086                 userArgsVals[1] = _method;
00087                 userArgsVals[2] = argVals;
00088                 method.invoke(_user, userArgsVals);
00089             }
00090         } catch (Exception ex) {
00091             ErrorStreamArea.println("JavaFuncDialog: " + ex + ", method: " + method);
00092             ex.printStackTrace();
00093         }
00094         setCursor(oldCursor);
00095     }
00096     setVisible(false);
00097 }


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:22 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001