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.
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.
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.
You can embed the mother of all open source rich text editors in a Swing app: OpenOffice.org provides an "OOBean", using which you can embed a full OpenOffice instance in a Swing app.
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).
There are also a bunch of commercial ones available, assuming you have a budget :)