SHEF is an HTML editing framework and component for the Java Swing GUI library. It can be plugged into the javax.swing.JEditorPane text component adding usable HTML WYSIWYG editing capabilities. In addition, SHEF works around various JEditorPane quirks and adds functionality currently missing from the standard Swing text implementation.

SHEF's current feature set includes (in no particular order):

  • HTML Source Editor with Syntax Highlighting
  • Context sensitive Swing Actions
  • Unlimited Undo/Redo
  • Table creation and editing
  • Click+Drag Resizable Tables
  • Click+Drag Resizable Images
  • Easily embeddable in Swing Applications or Applets
  • All the basic features you'd expect in an HTML Editing Component

Launch the demo
launch shef

Using SHEF

Using SHEF in applications or applets is straightforward. Simply create a new instance of HTMLEditorPane and use it as any other Swing Component. For instance, adding the editor to a JFrame:

HTMLEditorPane editor = new HTMLEditorPane();
JFrame frame = new JFrame();

The editor also includes pre-built edit, format, and insert menus that can be added to a JMenuBar

JMenuBar menuBar = new JMenuBar();

In addition to the component, SHEF includes a set of HTMLTextEdit Swing Actions that allows more flexibility. These actions can be set up with an editor manually to provide custom editing capabilities. Static methods in the HTMLEditorActionFactor class can create lists of these actions.


Or you can instantiate the Actions directly:

new HTMLFontColorAction();
new HTMLLinkAction();
new HTMLImageAction();


Most of SHEF's core functionallity is implemented through WysiwygHTMLEditorKit, a subclass of javax.swing.text.html.HTMLEditorKit. Setting up a WysiwygEditorKit on a JEditorPane:

JEditorPane editor = new JEditorPane();
editor.setEditorKitForContentType("text/html", new WysiwygHTMLEditorKit());



  • Currently the editor only supports HTML 3.2 because that's all that JEditorPane supports. It would be nice to find a way to work around this limitation, or at least add proper css formatting options.
  • The editor does not properly display images when left or right aligned.
  • Still plenty of formatting quirks
  • Code base needs refactoring and better documentation

Thanks To

SHEF uses the following libraries:

This project is licensed under the LGPL 2.1