寻找一个高效的基于Java Swing的控制台 [英] Looking for an efficient Java Swing based console

查看:545
本文介绍了寻找一个高效的基于Java Swing的控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个高效的Swing Java组件,我可以只插入我的应用程序UI。我已经尝试使用Swing中的类,如JTextArea没有可用;他们只是不够高性能足够和有任何棘手的缺点。此外,如果它有标准的控制台功能,如滚动锁,清除控制台,颜色等将是很好。

I'm looking for a highly efficient Swing Java component which I can just plug into my application UI. I already tried using the classes within Swing such as JTextArea with no avail; they simply aren't high-performance enough and have any crippling drawbacks. Additionally, it'd be nice if it had standard console features such as scroll-lock, clear console, colours, and so on.

编辑:忘了说,这个控制台将有大量调试信息流入其中,并且需要完全滚动。

Forgot to say, this console will have a lot of debug information streaming into it, and it needs to be fully scrollable.

干杯,

Chris

Cheers,
Chris

推荐答案

我看不出使用JTextPane有什么问题。它支持可以在每个文本段添加到控制台时指定的属性。清除它也显然是没有脑子。当添加到滚动窗格时,它也支持滚动。

I fail to see what is wrong with using a JTextPane. It supports attributes which you can specify as each piece of text is added to the console. Clearing it is also obviously a no brainer. When added to a scroll pane it also supports scrolling.

您可以使用智能滚动


太早了,

Plus, it removes text too early and

不知道这是什么意思,因为文本从未被删除,除非您特意将其从文档中删除。

No idea what that means as text is never removed unless you specifically remove it from the document.


不允许用户在输入
输入时(afaik)滚动。
效果是你只是看到文本
闪烁,而行数
保持不变。

doesn't allow the user to scroll while input is being entered (afaik). The effect is that you just see text flashing while the number of rows remains the same.

默认情况下,文本会自动滚动,因为文本附加到文档,假定代码在EDT上执行。

By default the text scrolls automatically as text is append to the document assuming the code is executed on the EDT. This scrolling can be controlled the the example provided in the link above.

编辑:


但我仍然喜欢图书馆解决方案

but I'd still like a library solution

我不知道任何


自动变色文字来自
不同的流

auto-colourise text coming from different streams

Message Console 可能会提供一些建议。

The Message Console might give you some ideas.


(即,检测
行上的[error]前缀)和基于
的colourise行this this

(i.e., detect [error] prefix on a line) and colourise lines based on this)

这可以通过在文本窗格的Document中添加一个DocumentFilter来轻松实现。您可以添加属性,因为文本插入到文档中。

This is easily done by adding a DocumentFilter to the Document of the text pane. You can add attributes as text is inserted into the Document.

这篇关于寻找一个高效的基于Java Swing的控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆