import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

    // Display the contents of a URL document in an editor pane.
class SwingTextFrame3 extends JFrame {
    public SwingTextFrame3() {
        final int width = 300, height = 300;
        setSize(width,height);
        Container contents = getContentPane();

        contents.add(new QuitJButton(),"South");
    }

        // Show the given file in the editor pane.
    public void showDocument(String url){
        try{
            JEditorPane ed = getEditor();
            if(ed == null){
                ed = new JEditorPane(url);
                ed.setEditable(false);
                getContentPane().add(new JScrollPane(ed),"Center");
            }
            else{
                ed.setPage(url);
            }
            validate();
        }
        catch(IOException e){
            JOptionPane.showMessageDialog(
                    getContentPane(),
                    e.toString(),
                    "URL Failure",
                    JOptionPane.ERROR_MESSAGE);
        }
    }

    protected JEditorPane getEditor(){
        return editor;
    }

    protected void setEditor(JEditorPane e){
        editor = e;
    }

    private JEditorPane editor;
}
