import java.awt.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.text.*;
import netscape.javascript.JSObject;

public class HTMLEditor extends Applet
{
	Stylepad style;

	public void init()
	{ 
	// Create the UI
	setLayout(new BorderLayout());
	String body = getParameter("body");
	String html = "";
	try {
		JSObject win = JSObject.getWindow(this);
		String empty[] = new String[0];
		html = (String)win.call("get_html", empty);
		}
	catch(Exception e) {
		html = "<b>"+e.getClass().getName()+" : "+e.getMessage()+"</b>\n";
		e.printStackTrace();
		}
	System.out.println("html = "+html);
	style = new Stylepad();
	style.setHTML(html);
	add("Center", style);
	}

	public String get_html()
	{
	return style.getHTML();
	}
}

