Frame1.java~6~
资源名称:Java.rar [点击查看]
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:4k
源码类别:
Java编程
开发平台:
Java
- package uml_gaokai;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author unascribed
- * @version 1.0
- */
- public class Frame1 extends JFrame {
- private JPanel contentPane;
- private JMenuBar jMenuBar1 = new JMenuBar();
- private JMenu jMenuFile = new JMenu();
- private JMenuItem jMenuFileExit = new JMenuItem();
- private JMenu jMenuHelp = new JMenu();
- private JMenuItem jMenuHelpAbout = new JMenuItem();
- private JToolBar jToolBar = new JToolBar();
- private JButton jButton1 = new JButton();
- private JButton jButton2 = new JButton();
- private JButton jButton3 = new JButton();
- private ImageIcon image1;
- private ImageIcon image2;
- private ImageIcon image3;
- private JLabel statusBar = new JLabel();
- private BorderLayout borderLayout1 = new BorderLayout();
- private JMenuItem jMenuItem1 = new JMenuItem();
- //Construct the frame
- public Frame1() {
- enableEvents(AWTEvent.WINDOW_EVENT_MASK);
- try {
- jbInit();
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
- //Component initialization
- private void jbInit() throws Exception {
- image1 = new ImageIcon(uml_gaokai.Frame1.class.getResource("openFile.gif"));
- image2 = new ImageIcon(uml_gaokai.Frame1.class.getResource("closeFile.gif"));
- image3 = new ImageIcon(uml_gaokai.Frame1.class.getResource("help.gif"));
- //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
- contentPane = (JPanel) this.getContentPane();
- contentPane.setLayout(borderLayout1);
- this.setSize(new Dimension(400, 300));
- this.setTitle("Frame Title");
- statusBar.setText(" ");
- jMenuFile.setText("File");
- jMenuFileExit.setText("Exit");
- jMenuFileExit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jMenuFileExit_actionPerformed(e);
- }
- });
- jMenuHelp.setText("Help");
- jMenuHelpAbout.setText("About");
- jMenuHelpAbout.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jMenuHelpAbout_actionPerformed(e);
- }
- });
- jButton1.setIcon(image1);
- jButton1.setToolTipText("Open File");
- jButton2.setIcon(image2);
- jButton2.setToolTipText("Close File");
- jButton3.setIcon(image3);
- jButton3.setToolTipText("Help");
- jMenuItem1.setText("登录");
- jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- jMenuItem1_actionPerformed(e);
- }
- });
- jToolBar.add(jButton1);
- jToolBar.add(jButton2);
- jToolBar.add(jButton3);
- jMenuFile.addSeparator();
- jMenuFile.add(jMenuItem1);
- jMenuFile.add(jMenuFileExit);
- jMenuHelp.add(jMenuHelpAbout);
- jMenuBar1.add(jMenuFile);
- jMenuBar1.add(jMenuHelp);
- this.setJMenuBar(jMenuBar1);
- contentPane.add(jToolBar, BorderLayout.NORTH);
- contentPane.add(statusBar, BorderLayout.SOUTH);
- }
- //File | Exit action performed
- public void jMenuFileExit_actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- //Help | About action performed
- public void jMenuHelpAbout_actionPerformed(ActionEvent e) {
- Frame1_AboutBox dlg = new Frame1_AboutBox(this);
- Dimension dlgSize = dlg.getPreferredSize();
- Dimension frmSize = getSize();
- Point loc = getLocation();
- dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
- dlg.setModal(true);
- dlg.pack();
- dlg.show();
- }
- //Overridden so we can exit when window is closed
- protected void processWindowEvent(WindowEvent e) {
- super.processWindowEvent(e);
- if (e.getID() == WindowEvent.WINDOW_CLOSING) {
- jMenuFileExit_actionPerformed(null);
- }
- }
- void jMenuItem1_actionPerformed(ActionEvent e) {
- }
- }