Create a Frame, Menu, and Scribble component
super("SerialziedScribble"); // Create the window.
final Scribble scribble;
scribble = new Scribble(this, 300, 300); // Create a bigger scribble area.
this.add(scribble, "Center"); // Add it to the ScrollPane.
MenuBar menubar = new MenuBar(); // Create a menubar.
this.setMenuBar(menubar); // Add it to the frame.
Menu file = new Menu("File"); // Create a File menu.
menubar.add(file); // Add to menubar.
// Create three menu items, with menu shortcuts, and add to the menu.
MenuItem load, save, quit;
file.add(load = new MenuItem("Load"));
file.add(save = new MenuItem("Save"));
file.addSeparator(); // Put a separator in the menu
file.add(quit = new MenuItem("Quit"));
// Create and register action listener objects for the three menu items.
load.addActionListener(new ActionListener() { // Open a new window
public void actionPerformed(ActionEvent e) { scribble.load(); }
});
save.addActionListener(new ActionListener() { // Close this window.
public void actionPerformed(ActionEvent e) { scribble.save(); }
});
quit.addActionListener(new ActionListener() { // Quit the program.
public void actionPerformed(ActionEvent e) { System.exit(0); }
});
// Another event listener, this one to handle window close requests.
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { System.exit(0); }
});
// Set the window size and pop it up.
this.pack();
this.show();