EditLive! 9 Documentation : Getting the Body in the Swing SDK Code

 * Copyright (c) 2005 Ephox Corporation.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.ephox.editlive.*;
import javax.jnlp.*;
/**  This tutorial shows developers how to extract the <BODY> of
 * a Document stored in EditLive! for Java Swing
public class GetBody extends JFrame implements ActionListener {
       /**        Buttons used to get html contents of EditLive! and copy to JTextArea source */
       private JButton bodyButton = new JButton("Get <BODY>");
       /** Allows users to enter html content to insert into EditLive!, or holds a copy of the html contents of EditLive! */
       private JTextArea source = new JTextArea(10, 30);
       /** html content to appear in the instance of EditLive! */
       private static final String INITIAL_HTML = "<p>Original <i>HTML</i> loaded into EditLive!</p>";
       /** Base class for EditLive! */
       private ELJBean editLiveBean = new ELJBean(INITIAL_HTML, "", 700, 300, getClass().getResource("sample_eljconfig.xml"), false);
       /** Creates JFrame and adds all class properties. Adds action listener to JButtons in JFrame
       public GetBody() throws Exception {
               super("Tutorial - Getting the <BODY> of the EditLive! Document");
               this.getContentPane().setLayout(new GridLayout(2, 1));
               SwingUtilities.invokeAndWait(new Runnable() {
                       public void run() {
                               // initialize EditLive!
               // Create a JPanel to hold the ELJBean
               JPanel editorHolder = new JPanel(new FlowLayout());
               // Add the JPanel to the JFrame
               // Create a JPanel to hold the button and the text area
               JPanel buttonAndText = new JPanel(new BorderLayout());
               // create a JPanel to hold the button
               JPanel buttonHolder = new JPanel(new FlowLayout());
               // add listener to button
               // add button holding panel
               buttonAndText.add(buttonHolder, BorderLayout.NORTH);
               // specify textarea content
               source.setText("Pressing the above button will copy the contents of the <BODY> attribute in EditLive! into this textarea.");
               // create scrollable pane to hold text area
               JScrollPane textAreaHolder = new JScrollPane(source);
               // add button and textarea to frame
               this.getContentPane().add(buttonAndText, BorderLayout.CENTER);
               // Display the JFrame.
               this.setSize(new Dimension(710, 640));
               // Adding a listener to detect if the JFrame is closing, to close the application if needed.
               addWindowListener(new WindowAdapter() {
                       public void windowClosing(WindowEvent e) {
       /** ActionListener for JButtons on the JFrame
        * @param e ActionEvent sent by JButton
       public void actionPerformed(ActionEvent e) {                        
               if (e.getSource() == bodyButton) {
                       try  {
                               SwingUtilities.invokeAndWait(new Runnable() {
                                       public void run() {
                       } catch (Exception exception) {
       /** Sets up the application and begins its execution
        * @param args the command line arguments - ignored
       public static void main(String args[]) throws Exception {
               try {
               } catch(Exception e) {
                       System.out.println("Unable to locate UIManager class");
               new GetBody();