gpt4 book ai didi

java - Jess打印输出内容用Java打印

转载 作者:行者123 更新时间:2023-12-01 11:36:58 26 4
gpt4 key购买 nike

我正在尝试从规则的 Jess RHS 获取打印输出内容。这里描述了类似的问题:Output of JESS in Java但如何使用路由器进行打印输出命令还没有具体的解决方案。我不想在 Java 控制台中打印规则的打印输出内容,而是想在专用的 JTextArea 中打印它们。我声明了一个字符串,例如String result; 保存内容,然后通过 outputTxt.setText(result);

将字符串内容打印到 JTextArea 中

最佳答案

Jess 手册明确地讨论了这种情况;请参阅http://www.jessrules.com/jess/docs/71/library.html#routershttp://www.jessrules.com/jess/docs/71/library.html#reader 。这真的再简单不过了:

 // Create a text area; you'll need to add it to your GUI, of course
TextArea ta = new TextArea(20, 80);
// This is a sort of adapter that lets Jess print into a textarea.
// There's also a JTextAreaWriter for Swing GUIs
TextAreaWriter taw = new TextAreaWriter(ta);
// Create a rule engine instance
Rete engine = new Rete();
// Connect the "t" router to the TextArea. From this point on,
// Jess code that executes "(printout t ..." will send its output
// to the TextArea
engine.addOutputRouter("t", taw);

关于java - Jess打印输出内容用Java打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29871782/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com