// This example is from _Java Examples in a Nutshell_. (http://www.oreilly.com)
// Copyright (c) 1997 by David Flanagan
// This example is provided WITHOUT ANY WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for non-commercial purposes.
// For any commercial use, see http://www.davidflanagan.com/javaexamples

import com.sun.java.swing.*;       // Beta package name; will change
import java.awt.*;

/**
 * This class demonstrates the use of the JInternalFrame class,
 * and also the use of JFC menus.  The class is a subclass of JLayeredPane,
 * which is the container required for use when JInternalFrame objects
 * are being used.
 **/
public class InternalFramePanel extends JLayeredPane {
  public InternalFramePanel() {
    // Create two JInternalFrame objects, with different titles and 
    // window decorations
    JInternalFrame f1 = new JInternalFrame("Frame 1", true, true, true, true);
    JInternalFrame f2 = new JInternalFrame("Frame 2", true, true, false,false);

    // Set the size and position of the windows
    f1.setBounds(20, 20, 150, 200);
    f2.setBounds(100, 150, 250 , 125);

    // Add the internal frames to this panel.  No layout manager is required
    this.add(f1);
    this.add(f2);

    // Now create a pulldown menu system.

    // Begin with a menubar
    JMenuBar menubar = new JMenuBar();

    // Create two menus for it, and add them to the menubar
    JMenu file = new JMenu("File");
    JMenu view = new JMenu("View");
    menubar.add(file);
    menubar.add(view);

    // Add a number of items, and a separator to the File menu
    file.add(new JMenuItem("New"));
    file.add(new JMenuItem("Open..."));
    file.add(new JMenuItem("Save"));
    file.add(new JMenuItem("Save As..."));
    file.add(new JSeparator());
    file.add(new JMenuItem("Quit"));

    // Add some items to the View menu
    view.add(new JCheckboxMenuItem("Show Toolbar"));
    view.add(new JCheckboxMenuItem("Show Color Palette"));
    view.add(new JCheckboxMenuItem("Show Java Console"));

    // Set a layout manager for JInternalFrame f1, and add the menubar
    // at the top of that "window".
    f1.setLayout(new BorderLayout());
    f1.add(menubar, "North");
  }
}
