redirect java console content to UI jframe

24 views
Skip to first unread message

lolo lolo

unread,
Apr 1, 2016, 2:55:05 PM4/1/16
to SWI-Prolog

I have a prolog file (Expert System) that I consult from Java using Jpl libraries (org.jpl7.*) and I have an UI using jframe where I want to show the output of prolog's queries.when consult prolog file in netbeans,read() predicate runs in console java;i want run in jtextarea in interface.Can anyone tell me how I can do that?

In this UI I have jtextarea for answer and another jtextarea for grade. This is prolog code using swi prolog:

start(Answer,Total_grade):-
Question1  = "Define computer?",
Word_list1 = ["software","operatingsystem"],
Word_list2 = ["hardware","tools"],
Msg = "Write your answers ",
write(Question1),nl,
write(Msg),nl,nl,
read(Answer),
string_lower(Answer,Low_answer),
split_string(Low_answer," ,.()-_"," ,.()-_", Answer_in_list),
find(Answer_in_list,Word_list1,Grade1),
find(Answer_in_list,Word_list2,Grade2),
Total_grade is Grade1 + Grade2,
nl,write("Your grade is : "), write(Total_grade),nl.

This is netbeans code:

String t1="consult('C:/Users/user/Desktop/prolog/s.pl')";
Query q1=new Query(t1);
Boolean t=q1.hasSolution(); 
String c1="start(Answer,Total_grade)";
Query c=new Query(c1);
Term f2=c.oneSolution().get("Total_grade");
String b2=f2.toString();
jTextArea2.setText(b2);
Reply all
Reply to author
Forward
0 new messages