Can anyone recommend a Java rich text editor? [closed]

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

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


Asked by: Edgar170 | Posted: 21-01-2022

Answer 1

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.

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.

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()).

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.

Answered by: Rubie993 | Posted: 22-02-2022

Answer 2

Try the MetaPhase editor, based on Charles Bell's HTMLDocumentEditor. It's LGPL v3 licensed and it's great, particularly as an example of using the StyledEditorKit, discussed here.

Answered by: Kristian641 | Posted: 22-02-2022

Answer 3

You can embed the mother of all open source rich text editors in a Swing app: provides an "OOBean", using which you can embed a full OpenOffice instance in a Swing app.

Answered by: Ned866 | Posted: 22-02-2022

Answer 4

I checked around and I can't find a jar file with just a text editor in it. However, heres 2 other options

Option A Use Swing and build one yourself. Swing has a lot of the componenets already covered in javax.swing.text, although it still requires an extensive amount of code. I found an example here

Option B Scavenge code from an open source project. I found 2 projects with realy nice HTML WYSIWYG type editors that can be extracted (both are contained in just a few classes).

  1. Memoranda (GPL): Its text edit or is in net.sf.memoranda.ui.htmleditor.HTMLEditor. Its a JPanel and only uses one other class.
  2. Ekit (LGPL): Its a full featured WYSIWYG Html editor. Its com.hexidec.ekit.EkitCore class is a JPanel and seems fairly multipurpose, although it uses a lot of other classes from the package.

There are also a bunch of commercial ones available, assuming you have a budget :)

Answered by: Anna164 | Posted: 22-02-2022

Answer 5

Have a look at JWord or JRichTextEditor

JWord is a commercial swing rich text editor, with tables, paging and RTF/opendoc/XML support. Also supports header/footer, multi-column layout, export HTML, SVG, WMF etc.

JRichTextEditor is an open source swing widget, that's quite ok for note taking. Supports images, a simple XML format for storage, export to PDF, HTML. Not as advanced as JWord, but open source.

Might help.

Answered by: John476 | Posted: 22-02-2022

Similar questions

Which JavaScript library you recommend to use with Java EE + Struts + iBatis?

Closed. This question does not meet Stack Overflow guid...

What ec2 image (ami) do you recommend for working with java 5, jboss, mysql, apache?

What ec2 image (ami) do you recommend for working with java 5, jboss, mysql, apache?

Can anyone recommend an off the shelf ACL Java lib?

I'm not having any luck finding one.

Can you recommend a java portlet software?

Closed. This question does not meet Stack Overflow guid...

Recommend Linux + Java books, resources for .NET developer

Closed. This question is off-topic. It is not curre...

Recommend a Java / Android Game Library - card, board, etc.?

Closed. This question does not meet Stack Overflow guid...

java - Recommend me a good JNI book

logging - Can someone recommend a good unix syslog *client* library for java?

Closed. This question does not meet Stack Overflow guid...

Recommend an indexed file format that can be updated via random access in Java

I need an indexed file format that can hold a few hundred large variable sized binary blobs. Blobs are around 1-5MB and the file could be as large as 1 GB. I need to be able to quickly find, read, add and remove blobs without recreating the the entire file. I have no need to compress the blobs, however if blobs were removed, I'd like to reclaim or reuse the space. Ideally there would be a Java API.

Recommend non GPL XMPP server in java

It seems nearly all the XMPP java servers such as OpenFire, Tigrese are GPL.

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)