[kepler-dev] Do you know whats wrong?

Peter Reutemann fracpete at gmail.com
Tue Mar 31 22:38:11 PDT 2009


> I am just trying to convert this into a yes no decision maker.
> Can u please suggest whats wrong?
> Thanks!
> /**
>  *
>  */
> package org.userinputmod;
> import javax.swing.JOptionPane;
> import ptolemy.actor.TypedIOPort;
> import ptolemy.actor.lib.LimitedFiringSource;
> import ptolemy.data.StringToken;
> import ptolemy.data.expr.Parameter;
> import ptolemy.data.type.BaseType;
> import ptolemy.kernel.CompositeEntity;
> import ptolemy.kernel.util.IllegalActionException;
> import ptolemy.kernel.util.NameDuplicationException;
> /**
>  * @author Subhav
>  *
>  */
> public class UserInputMod extends LimitedFiringSource {
> public Parameter user;
> public TypedIOPort opeqtrue;
> public TypedIOPort opeqfalse;
> /**
> * @param containert
> * @param name
> * @throws NameDuplicationException
> * @throws IllegalActionException
> */
> public UserInputMod(CompositeEntity container, String name)
> throws NameDuplicationException, IllegalActionException {
> super(container, name);
> output.setTypeEquals(BaseType.STRING);
> opeqtrue= new TypedIOPort(this, "opeqtrue", false, true);
> opeqfalse= new TypedIOPort(this, "opeqfalse", false, true);
> //output.setTypeEquals(BaseType.INT);
> user = new Parameter(this,"user");
> }
> /* (non-Javadoc)
> * @see ptolemy.actor.lib.Source#fire()
> */
> @Override
> public void fire() throws IllegalActionException {
> super.fire();
> String reply = JOptionPane.showInputDialog("Please enter 'yes' or 'no'");
>   if (reply == "yes")

You have to use the following code, otherwise you're comparing two
different objects, which will never succeed:
  if (reply.equals("yes"))

[...]

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