Hello,

I have a choice box that is behaving strangely.  It is supposed to print out 
"Connecting to _____" and then either Simulator or Robot.  It works for 
simulator, but not for Robot.  If I change Robot to anything else, it works 
fine.  What is going on here?

Matt
(import java.awt.*)
(import jess.awt.*)

(assert (mode initialize))
(assert (need target-prompt))

;; **********************************************************************
;; Rules and functions for Target Prompt

(defrule create-target-prompt 
  (mode initialize)
  ?fact <- (need target-prompt)
  =>
  ;create frame
  (bind ?*f* (new Frame "Target Prompt"))
  (set ?*f* layout (new GridLayout 2 1))
  ;add widgets
  (bind ?*p1* (new Panel))
  (?*p1* add (new Label "Welcome to the Pionner Delivery System"))
  (?*f* add ?*p1*)
  (bind ?*p2* (new Panel))
  (?*p2* add (new Label "Please choose target: "))
  (bind ?*m* (new Choice))
  (?*m* addItem "Simlator")
  (?*m* addItem "Robot")
  (?*p2* add ?*m*)
  (?*f* add ?*p2*)
  ;add behaviours
  (?*f* addWindowListener
        (new WindowListener target-prompt-handler (engine)))
  (?*m* addItemListener
        (new ItemListener target-prompt-menu-handler (engine)))
  ;show target prompt
  (?*f* validate)
  (?*f* pack)
  (?*f* show)
  (retract ?fact))

(deffunction target-prompt-menu-handler (?event)                                       
 
  (printout t "Connecting to " (call (get ?event item) toString) crlf))
 

Reply via email to