Hi, I am using a java frame as a menu to let user enter some inputs. The java program will then construct a assert string and send it to JESS to be processed and get back a JESS object.
I read the "JESS in action" book but I'm still confused, how do I run the JESS and pass the assert string to it. How can I get the output of the JESS program? I have attached a scaled down version of my program, at "send to jess" button click it will send a string to JESS, and JESS is suppose to return a user-shoes fact to java, recommending soccer-boots. http://www.geocities.com/t_web_design/TestFrame.java http://www.geocities.com/t_web_design/shoes.txt (yahoo won't let me upload it as shoes.clp) I'm justing java 1.509 (and IDE JCreator) and Jess61p4. Can you please point me to a similar example or please help me with the codes? thanks a bunch and rgds rick Below is the code of the above 2 files **************************************************************************** import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import java.text.*; public class TestFrame extends JFrame implements ActionListener{ //declare JTextFields for input private JTextField inputField, outputField; //declare JLabel for labelling private JLabel inputLabel, outputLabel;; //declare buttons private JButton exitButton, computeButton; //frame method public TestFrame(){ //frame's settings setTitle("version 1.0"); //set title of frame setBounds(50,50,650,200); //set window //PANEL:input, to put the input & output fields JPanel inputPanel = new JPanel(); inputPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); inputLabel = new JLabel("String to pass to Jess: "); inputField = new JTextField(40); outputLabel = new JLabel("Jess to return something: "); outputField = new JTextField(40); //add the Label & Field into the panel inputPanel.add(inputLabel); inputPanel.add(inputField); inputPanel.add(outputLabel); inputPanel.add(outputField); inputField.setText("(assert (user (age 27) (weight 120) (height 509) (ex-program soccer) )) "); //PANEL:button, store 3 buttons, contentPane=SOUTH JPanel buttonPanel = new JPanel(); //create Panel for 'button' buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); //set flow layout computeButton = new JButton("Sent to Jess"); //create 'compute' button exitButton = new JButton("Exit"); //create 'exit' button buttonPanel.add(computeButton); //add 'compute' button into Panel buttonPanel.add(exitButton); //add 'exit' button into Panel computeButton.addActionListener(this); //add listener to 'compute' button exitButton.addActionListener(this); //add listener to 'exit' button Container contentPane = getContentPane(); contentPane.add(buttonPanel, BorderLayout.SOUTH); //add buttonPanel to SOUTH contentPane.add(inputPanel, BorderLayout.CENTER); //add inputPanel to CENTER } //close GymTrainerFrame() //detect mouse click public void actionPerformed(ActionEvent e){ Object source = e.getSource(); //get source of click if (source == exitButton) //check if exit button is clicked { System.exit(0); } //exit prog if (source == computeButton) //if clear button is clicked { //send to JESS } } //close actionPerformed() //MAIN: make the frame show up public static void main(String[] args) { JFrame frame = new TestFrame(); //create the frame frame.show(); //show the frame } //close main } ************************************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;user object (deftemplate user (slot age) (slot weight) (slot height) (slot ex-program) );;close ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;user footwear object (deftemplate user-footwear (slot ident) );;close ;;;;;;;;;;;;;;;;;;;;;;;;;;;; check if user is playing soccer, if so recommend soccer boots (defrule print-user (user (ex-program soccer)) => (assert (user-footwear (ident soccer-boots))) );;close (reset) (focus) (run) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;code to create user fact with user playing soccer ;;;(assert (user (age 27) (weight 120) (height 509) (ex-program soccer) )) -- View this message in context: http://www.nabble.com/How-to-use-java-interface-to-pass--get-facts-from-JESS-tf3421248.html#a9535635 Sent from the Jess mailing list archive at Nabble.com. -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
