将java控制台内容重定向到UI jframe

时间:2016-03-30 19:36:12

标签: java netbeans console prolog jpl

我有一个prolog文件(专家系统),我使用Jpl库(org.jpl7。*)从Java咨询,我有一个使用jframe的UI,我想显示prolog的查询的输出。当参考prolog文件时netbeans,read()谓词在控制台java中运行;我想在接口中的jtextarea中运行。任何人都告诉我如何做到这一点?

在这个UI中,我有jtextarea的答案和另一个jtextarea等级。 这是使用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.

这是netbeans代码:

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);

0 个答案:

没有答案