任何人都可以推荐Java富文本编辑器吗? [英] Can anyone recommend a Java rich text editor?

查看:202
本文介绍了任何人都可以推荐Java富文本编辑器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

富文本编辑器必须用Java实现,提供Swing支持,最好是开源的。

The rich text editor must be implemented in Java, provide Swing support, and preferably be open source.

我希望将它集成到现有的Java / Swing应用程序。

I'm looking to integrate it into an existing Java/Swing application.

谢谢。

推荐答案

这可能不是昙花一现 - 就像你所追求的那样......但JTextPane支持富文本和HTML。
将它设置为 display rtf或html很简单,只需在填充内容之前设置编码类型即可。

This is probably not as drop-in-place as what you were after... but JTextPane supports rich text and HTML. Its trivial to get it to display rtf or html, just set the encoding type before you fill it with content.

至于制作小B和 I 等样式修改按钮,如果它归结为它,那么捏这不是很难让自己。
认为JButtons设置了图标。他们的听众获得JTextPane当前选择的开始和结束索引位置,如下所示:
jpane.getSelectionStart() jpane.getSelectionEnd()
然后在这些位置插入打开和关闭html / rtf标记。

As for making the little "B" and "I" etc style-modifying buttons, well if it came down to it, in a pinch that wouldnt be very hard to make yourself. Think JButtons with Icons set. Their listeners get JTextPane's current selection start and end index positions like this : jpane.getSelectionStart() or jpane.getSelectionEnd() and then insert opening and closing html/rtf tags at those locations.

撤销也很简单 - 每次用户执行编辑操作时,维护一个简单的Jpanel字符串内容堆栈,一个简单的历史记录.push(jpane.getText())会存储状态,撤消按钮就像 jpane.setText(history.pop())

Undo is easy too - maintain a simple stack of the string contents of the Jpanel, every time the user does an edit action, a simple history.push(jpane.getText()) would store the state, and the undo button would be as simple as jpane.setText(history.pop()).

我/你可以用B做个,&在大约30分钟内撤消我估计 - 像列表这样的其他按钮需要更长时间,但不是很多。

I/you could make one with B, I & undo in around 30 min I reckon - other buttons like lists will take longer, but not much so.

这篇关于任何人都可以推荐Java富文本编辑器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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