FileDocCategorySizeDatePackage
PageFrame.javaAPI DocExample1803Thu Oct 24 20:14:20 BST 2002None

PageFrame

public class PageFrame extends JInternalFrame implements ActionListener

Fields Summary
SiteManager
parent
String
filename
JTextArea
ta
Constructors Summary
public PageFrame(String name, SiteManager sm)

    super("Page: " + name, true, true, true, true);
    parent = sm;
    setBounds(50,50,300,150);

    Container contentPane = getContentPane();

    // Create a text area to display the contents of our file in
    // and stick it in a scrollable pane so we can see everything
    ta = new JTextArea();
    JScrollPane jsp = new JScrollPane(ta);
    contentPane.add(jsp, BorderLayout.CENTER);

    JMenuBar jmb = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem saveItem = new JMenuItem("Save");
    saveItem.addActionListener(this);
    fileMenu.add(saveItem);
    jmb.add(fileMenu);
    setJMenuBar(jmb);

    filename = name;
    loadContent();
  
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent ae)

    // Can only be the save menu
    saveContent();
  
public voidcopyText()

 ta.copy(); 
public voidcutText()

 ta.cut(); 
public voidloadContent()

    try {
      FileReader fr = new FileReader(filename);
      ta.read(fr, null);
      fr.close();
    }
    catch (Exception e) {
      System.err.println("Could not load page: " + filename);
    }
  
public voidpasteText()

 ta.paste(); 
public voidsaveContent()

    try {
      FileWriter fw = new FileWriter(filename);
      ta.write(fw);
      fw.close();
    }
    catch(Exception e) {
      System.err.println("Could not save page: " + filename);
    }