MyJFrame.java

/*
 * @author Hermann Wöhrmann
 *
 * Description:
 *
 * Version Date       Comments
 * 1.01.01 13.11.2004 created
 *
 */

import java.awt.*;
import javax.swing.*;
import speed.jg.*;

class MyJFrameGUI extends GUIObject
{
  protected MyJFrameGUI()
  { JFrame myJFrame = new JFrame();
    myJFrame.setBounds(64, 48, 640, 480);
    myJFrame.getContentPane().setLayout(new BorderLayout());
    myJFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    myJFrame.setTitle("Howto Examples");
    { JMenuBar myJMenuBar = new JMenuBar();
      { JMenu myJMenu = new JMenu();
        myJMenu.setText("File");
        myJMenu.setMnemonic('f');
        { JMenuItem mnNew = new JMenuItem();
          mnNew.setText("New");
          mnNew.setMnemonic('n');
          mnNew.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/New16.gif")));
          mnNew.setName("mnNew");
          super.add(mnNew);
          myJMenu.add(mnNew);
        }
        { JMenuItem mnOpen = new JMenuItem();
          mnOpen.setText("Open");
          mnOpen.setMnemonic('o');
          mnOpen.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/Open16.gif")));
          mnOpen.setName("mnOpen");
          super.add(mnOpen);
          myJMenu.add(mnOpen);
        }
        { JMenuItem mnClose = new JMenuItem();
          mnClose.setText("Close");
          mnClose.setMnemonic('c');
          mnClose.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/Export16.gif")));
          mnClose.setName("mnClose");
          super.add(mnClose);
          myJMenu.add(mnClose);
        }
        { JSeparator myJSeparator = new JSeparator();
          myJSeparator.setName("myJSeparator");
          super.add(myJSeparator);
          myJMenu.add(myJSeparator);
        }
        { JMenuItem mnExit = new JMenuItem();
          mnExit.setText("Exit");
          mnExit.setMnemonic('x');
          mnExit.setName("mnExit");
          super.add(mnExit);
          myJMenu.add(mnExit);
        }
        myJMenu.setName("myJMenu");
        super.add(myJMenu);
        myJMenuBar.add(myJMenu);
      }
      myJMenuBar.setName("myJMenuBar");
      super.add(myJMenuBar);
      myJFrame.setJMenuBar(myJMenuBar);
    }
    { JToolBar myJToolBar = new JToolBar();
      { JButton btnNew = new JButton();
        btnNew.setToolTipText("New File");
        btnNew.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/New24.gif")));
        btnNew.setName("btnNew");
        super.add(btnNew);
        myJToolBar.add(btnNew);
      }
      { JButton btnOpen = new JButton();
        btnOpen.setToolTipText("Open File");
        btnOpen.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/Open24.gif")));
        btnOpen.setName("btnOpen");
        super.add(btnOpen);
        myJToolBar.add(btnOpen);
      }
      { JButton myJButton = new JButton();
        myJButton.setToolTipText("Close File");
        myJButton.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/Export24.gif")));
        myJButton.setName("myJButton");
        super.add(myJButton);
        myJToolBar.add(myJButton);
      }
      myJToolBar.setName("myJToolBar");
      super.add(myJToolBar);
      myJFrame.getContentPane().add(myJToolBar, BorderLayout.NORTH);
    }
    { JDesktopPane myJDesktopPane = new JDesktopPane();
      { JInternalFrame myJInternalFrame = new JInternalFrame();
        myJInternalFrame.setBounds(0, 0, 320, 240);
        myJInternalFrame.setVisible(true);
        { JPopupMenu myJPopupMenu = new JPopupMenu();
          { JMenuItem popNew = new JMenuItem();
            popNew.setText("New");
            popNew.setMnemonic('n');
            popNew.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/New16.gif")));
            popNew.setName("popNew");
            super.add(popNew);
            myJPopupMenu.add(popNew);
          }
          { JMenuItem popOpen = new JMenuItem();
            popOpen.setText("Open");
            popOpen.setMnemonic('o');
            popOpen.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/Open16.gif")));
            popOpen.setName("popOpen");
            super.add(popOpen);
            myJPopupMenu.add(popOpen);
          }
          { JMenuItem popClose = new JMenuItem();
            popClose.setText("Close");
            popClose.setMnemonic('c');
            popClose.setIcon(new ImageIcon(GUIObject.getImageResource("/toolbarButtonGraphics/general/Export16.gif")));
            popClose.setName("popClose");
            super.add(popClose);
            myJPopupMenu.add(popClose);
          }
          { JSeparator popJSeparator = new JSeparator();
            popJSeparator.setName("popJSeparator");
            super.add(popJSeparator);
            myJPopupMenu.add(popJSeparator);
          }
          { JMenuItem popExit = new JMenuItem();
            popExit.setText("Exit");
            popExit.setMnemonic('x');
            popExit.setName("popExit");
            super.add(popExit);
            myJPopupMenu.add(popExit);
          }
          myJPopupMenu.setName("myJPopupMenu");
          super.add(myJPopupMenu);
          new PopupMenuController(myJPopupMenu, myJInternalFrame);
        }
        myJInternalFrame.setName("myJInternalFrame");
        super.add(myJInternalFrame);
        myJDesktopPane.add(myJInternalFrame);
      }
      myJDesktopPane.setName("myJDesktopPane");
      super.add(myJDesktopPane);
      myJFrame.getContentPane().add(myJDesktopPane, BorderLayout.CENTER);
    }
    myJFrame.setName("myJFrame");
    super.add(myJFrame);
  }
}

public class MyJFrame
{
  public MyJFrame()
  { GUIObject gui = new MyJFrameGUI();
    //MyJFrameController controller = new MyJFrameController(gui);
    JFrame frame = (JFrame) gui.getComponent("myJFrame");
    frame.show();
  }

  public static void main(String[] args)
  { MyJFrame myJFrame = new MyJFrame();
  }

}