WYSIWYG text editor in Java

51,333

Solution 1

RSyntaxTextArea

I've used this component and it works well. It is LGPL and it is based on javax.swing.text package (javax.swing.text.EditorKit). Since it is a Swing component it can be integrated in your application in a few lines of code :

RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
RTextScrollPane sp = new RTextScrollPane(textArea);

Solution 2

JWebEngine

I recommend JWebEngine. It is the only one that I know that passes the ACID1 browser test and the mail-acid test. Most other Java HTML editors are based on the javax.swing.text.html.HTMLDocument and have all the same bugs. The support of CSS is very poor with HTMLDocument. JWebEngine has very good support for viewing HTML with CSS.

  • Link to the website. There are also online samples.
  • Commercial license
  • It is very simple to extend. The vendor is using it for many different things like editor, HTML printing engine, showing custom placeholders, etc. There is no problem with the visibility of classes like with the Sun HTMDocument.
  • It based on javax.swing.text.JEditorPane or javax.swing.text.JTextPane and you can use it together with third party tools like the spell checker JOrtho.
  • It is pure Java and runs on all platform with Java SE 5 or higher. It also run in non-signed applets.

Solution 3

I needed the same thing for our application, did a research and found two more products EKit and Metaphase Editor, based on Charles Bell's HTMLDocumentEditor, both under LGPL license and looking good.

But I did not test them. These days we shall see what we choose.

Solution 4

OpenOffice's Writer

Can be embedded in Java using the OOoBean. The original code runs under Swing but you can make it work under SWT, too, using the AWT/SWT Bridge (example code).

The project is open source (LGPL). The code is OS dependent but there are versions available for all major OSs (Windows, Linux, MacOS and Solaris are supported on the project's site but you can download the source and compile it for others, as well).

Since the underlying product is a full blown office application, it offers all the features you might want (fancy styles, online spell checking in different languages, embedding pictures, flow text around pictures, you name it).

The drawback is that you must have OpenOffice installed; in fact, the editor is not part of Java but it's a remote process which just renders in your Java app's window. This means that start up time is quite noticeable and performance can be sluggish. Also handling is sometimes "odd". It takes some configuration to get rid of additional borders and unwanted document pagination.

Because of this, the editor is not really extendable from Java. You will either have to write code in C++ or using OOo's own built-in language. What you can do is you can register listeners in the document and you have full access to the underlying model for the document. This way, you can hook into the important parts and modify the behavior but this often feels like performing keyhole surgery.

My conclusion: If OO has the features you need, this might be the most simple way to get what you need. If you need a lot of customization, you'll fight an upstream battle against the framework's defaults.

Solution 5

Simply HTML

  • its GPLed
  • have no idea how easy it is to extend it
  • doesn't support spell checking, but has tables, lists.
  • Based on Swing, needs Java 1.4 and optionally Java Help
  • I didn't used it as a programmer - just as an end user, it has some quirks - like no multilevel list's or tables that are less than great but is OK.
  • Plus is it gives you HTML, so its is easy to embed results of processing into other components.
  • Now on SourceForge
Share:
51,333

Related videos on Youtube

Aaron Digulla
Author by

Aaron Digulla

I'm a software developer living in Switzerland. You can reach me at digulla at hepe dot com.

Updated on April 29, 2020

Comments

  • Aaron Digulla
    Aaron Digulla about 4 years

    I'd like to collect all WYSIWYG text editors for Java here.

    Some rules for entries:

    • There must be a link to the project/product
    • You must state whether it's open source or commercial
    • Is it possible to extend the editor (add new features like a "violet centered sudoku")? Is that simple or complex?
    • Does it come with lots of features (fancy character and paragraph styles with online spell checking for several languages in the same document) or just the basics (bold, italics, no underline)?
    • List important dependencies (does it run on bare Java with Swing? SWT? MacOS?)
    • Your personal opinion

    This list should help developers determine which editor to choose. I'm not looking for "the best" but more "what's there".

    • Oliver Watkins
      Oliver Watkins about 11 years
      what are you editing? HTML? binary?
    • Aaron Digulla
      Aaron Digulla about 11 years
      I don't have any preferences regarding the file format. With a powerful editor, it should be possible to write converters to read/write arbitrary formats.
  • Aaron Digulla
    Aaron Digulla about 15 years
    Take this as an example entry :)
  • Aaron Digulla
    Aaron Digulla about 15 years
    Is the code easy to extend or riddled with private/final/static? How about spell checking? Did you try to add your own formatting rules?
  • Harini
    Harini about 15 years
    Since it is based on javax.swing.text.EditorKit it is pretty flexible(it takes some time to get used with it, but once you get it it's easy). I had my own EditorKit but RSyntaxTextArea is better, much better. The code looks well written, it uses JFlex to tokenize the text, so you would need to write your own flex file to add a new syntax highlighter.A code completion add-on library was added at the end of last year and I presume a spell checker can be added to without too much effort. You can ask the author to add something like that, since he is more accommodated with the code.
  • Anne Porosoff
    Anne Porosoff over 14 years
    looks like the product is discontinued
  • Jim Ferrans
    Jim Ferrans over 14 years
    Simply HTML is now here: sites.google.com/site/uhilger/software/simplyhtml Click on "herunterladen" near the bottom to get a zip file.
  • Horcrux7
    Horcrux7 over 14 years
    The latest version is from 2003. I think the project is discontinued.
  • Tiberiu
    Tiberiu almost 13 years
    So I have tested both products and although are light and easy to integrate both are buggy and have a weird behavior.
  • Horcrux7
    Horcrux7 about 12 years
    Look in the online store at inetsoftware.de/store
  • Jeel Shah
    Jeel Shah about 11 years
    @adrian.tarau This is difficult to work with and the documentation is out of date. Are there any alternatives?
  • Harini
    Harini almost 11 years
    @gekkostate It's not perfect but it does its job. What do you mean by "This is difficult to work with"? to extend the library or to use it? There is code.google.com/p/jsyntaxpane, but I did not use it.
  • Jeel Shah
    Jeel Shah almost 11 years
    @adrian.tarau To be more specific. There is no .jar for the library. So you have to add it manually and then use it or make the project and then make the .jar yourself. The documentation and tutorials are not that great as the source that is provided is inconsistent.
  • Harini
    Harini almost 11 years
    Not sure I understand the issue here. You can download the latest release from sf.net (sourceforge.net/projects/rsyntaxtextarea/files/rsyntaxtexta‌​rea/…) and extract the library jar.
  • Jules
    Jules almost 10 years
    Not discontinued; the sourceforge site shows updates in 2014.
  • mawalker
    mawalker almost 7 years
    Currently the license fee for 'commercial' is 1950$ USD... So.. do what you will with that information... JWebEngine looks to be great... but the cost might be an issue for most people... (not OSS/library)