In order to create an instance of the EditLive! for Java Swing within a Java Application, developers need to utilize several different methods of the Bean to ensure the desired functionality. For detailed information on creating and modifying an instance of the EditLive! for Java Swing see the Java APIs

EditLive! for Java Swing Constructors

EditLive! for Java Swing provides several different constructors. The main difference between these constructors is the way in which they allow the EditLive! configuration file to be specified. EditLive! for Java Swing configuration files can also be specified using several different methods of the ELJBean. More information on these methods is depicted in the Specifying the Configuration File section of this page.

Specifying the Configuration File

An EditLive! for Java Swing configuration file is a single XML file used to specify numerous elements of the EditLive! for Java Swing editor. A configuration file facilitates the customization of the behavior and functionality of EditLive!for Java Swing . Almost the entire interface of EditLive! for Java Swing can be customized via the configuration file. Customization of the EditLive! for Java Swing interface may also include the development of custom functionality accessed via custom toolbar and menu items.

Because server-side languages can be used to generate documents of any types at run-time, configuration files can also be stored as server-side language files (e.g. JSP files, ASP files) as long as the file contains calls to render the information as XML at run-time.

In cases where either the settings in the document content of EditLive! for Java Swing or the settings specified through the Swing methods conflict with the settings in the configuration file, the settings in the configuration file will take precedence. For example, if the configuration file specifies style

H1{font-size: 10;}

and then the setStyles ELJBean method specifies

H1{font-size: 20} H2{font-size: 15}

, then the resulting embedded styles for the XHTML will still only be

H1{font-size: 10}

.

Configuration files can be created and edited by manually editing an EditLive! Configuration File using a text editor.

The ELJBean class provides the following constructors to allow developers to specify the configuration file:

The ELJBean class also supports specifying a configuration file using the following methods:

Instantiating EditLive! for Java Swing Example

The following example demonstrates how to use the default EditLive! for Java Swing constructor to instantiate the editor, as well as specify the EditLive! configuration file to be used.

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.ephox.editlive.*;
 
public class BasicExample {
       
       public static void main(String[] args) {
               // Create a new EditLive! instance.
               ELJBean elj = new ELJBean(false);
 
            // Specify Configuration File
            // NOTE: Ensure you have an EditLive! configuration file in the same directory as the BasicExample.java class.
            elj.setConfigurationURL(BasicExample.class.getResource("configFile.xml").toString());
 
               // Finally, initialize the bean.
               elj.init();
               
               // Set up a JFrame and add the bean to it.
               JFrame frame = new JFrame("Basic Example");
               frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
               
               frame.getContentPane().add(elj);
               
               frame.pack();
               frame.show();
       }
}

For more information, consult the Java APIs.

See Also