package prolog;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
 
import jpl.Atom;
import jpl.JPL;
import jpl.Query;
import jpl.Term;
import jpl.Variable;
 
@SuppressWarnings({ "unchecked", "deprecation", "serial" })
public class JavaProlog extends JFrame {
 
	JButton 	startButton = new JButton("Start");
	JTextArea 	textArea	= new JTextArea("This program diagnoses why a car won''t start.\n" +
											"Answer all questions with Y for yes or N for no.");
 
	/**
	 * Konstruktor - towrzy okienko z przyciskiem ktory wywoluje prologa
	 */
	JavaProlog(){
		Container cp=getContentPane();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
		setLocation	(200,200);
		setSize		(300,200);
		setLayout	(new FlowLayout());
 
 
		startButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				startDiagnose();
			}
		});
 
		cp.add(textArea2);
		cp.add(textArea);
		cp.add(startButton);
 
		setVisible(true);	
	}
 
	private void startDiagnose(){
		Query queryConsult = new Query("consult", new Atom("pl/carJPL.pl"));
		queryConsult.query();
 
		Query start = new Query("start");
		start.query();
	}
 
 
	public static void main( String argv[] ){
		JPL.init();
 
		JavaProlog jpTest = new JavaProlog();
 
	}/***** main *****/
}/**===  JavaProlog  ===*/
pl/miw/miw08_ruleruntimeg_2/pliki/javaprolog.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0