In my previous post I linked to a library that allows the use of native components within Java applications as easily as using Swing components. At the time of this post I had managed to get the Web Browser sample to compile and run in Netbeans 6.8 but was having troubles getting the HTML Editor to compile in Netbeans.
Over the last couple of days I have managed to get the HTML Editor compiled and running in Netbeans 6.8.
This post will demonstrate how to configure Netbeans to use the DJ NativeSwing library to embed a HTML Editor into a Java Swing Application.
The first step is to download a copy of the libraries required for DJ NativeSwing to function.
DJ NativeSwing
SWT - requires the M6 development build to function correctly.
FCKEditor- requires FCKEditor not the CKEditor Download
FCKEditor Java Plugin
Once you have downloaded all the class libraries unzip them to a handy directory. I use c:\java_util\ and create a separate directory for each class library.
The FCKEditor ZIP does not require unzipping. The FCKEditor java plugin takes care of this.
Open Netbeans and create a new Java Application and add the downloaded libraries to the project. Once completed the libraries tab should look like the image below.
Now that the project has been created you need to create the two class files the project requires. Rather than have masses of code in the post, I have included these class files for you to download.
HTMLEditor.java- this is the class that includes the main class. Refer to image below for this class. This was copied directly from the sample HTMLEditor code in the JavaWebstart sample on the DJ NativeSwing site.
SimpleHTMLEditorExample.java- this is the HTMLEditor class that extends JPanel and builds the HTML Editor control.
This class was slightly changed as it returned a compiler error in the state it was in on the DJ NativeSwing site.
In the screenshot below you can see where the call to create the new JHTMLEditor is returning an error. To make this code work correctly requires a change to specify what HTMLEditor implementation is to be used.
JHTMLEditor htmlEditor = new JHTMLEditor(JHTMLEditor.HTMLEditorImplementation.FCKEditor);
Once these minor changes have been completed, it should be possible to compile and run the project and get a HTML Editor with WYSIWYG editing.
I have included a
zipped file of the Netbeans Project for people to try out.
Enjoy.