Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Thanks.

like image 864
fred smith Avatar asked Oct 13 '08 08:10

fred smith


People also ask

Is Rich Text Editor Free?

Quill Rich Text EditorQuill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need.

Do you need a text editor for Java?

You need a tool that can compile and run Java programs and a text editor to write those programs. With most programming languages, computer programs are written by entering text into a text editor (also called a source code editor). Some programming languages come with their own editor.

What can you do with a rich text editor?

The Rich Text Editor is a tool that allows you to add or edit content, images, links, and other components on the page without having to know any code. It displays the content and any formatting as it would display in the browser.


2 Answers

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.

like image 153
dalyons Avatar answered Oct 10 '22 03:10

dalyons


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.

like image 23
user328744 Avatar answered Oct 10 '22 01:10

user328744