[kepler-dev] Help with Pop Up Box in Kepler

Peter Reutemann fracpete at gmail.com
Sat Mar 21 21:46:09 PDT 2009


> The working code for a pop-up box which accepts user values is given below:

[...]

> 1) Following my question about creating a pop-up box in Kepler which accepts
> user input, how should I go about implementing this functionality in Kepler
> ? ( The above code works on Eclipse)
> 2) I need to create an actor with an output port that takes this input value
> from the user and makes it available there. (So as to use this value in
> conjunction with other actors such as the Display actor)

Just a quick stab at what the fire() method of an actor could look
like (not tested whether Kepler likes user interaction):

  /**
   * Lets the user enter a value and broadcasts it.
   *
   * @throws IllegalActionException If there is no director.
   */
  public void fire() throws IllegalActionException {
    super.fire();

    String reply = JOptionPane.showInputDialog("Please enter value");
    if (reply == nul)
      return;

    output.broadcast(new StringToken(reply));
  }

Your actor would be derived from ptolemy.actor.lib.Source and the
output port would have to be of type STRING (defined in the actor's
constructor):
    output.setTypeEquals(BaseType.STRING);

Cheers, Peter
-- 
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/           Ph. +64 (7) 858-5174


More information about the Kepler-dev mailing list