• java中的记事本的最初几步


    package aaa;

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    /**
     * <p>Title: 记事本</p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2006</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */

    public class aaaFrame1 extends JFrame {
      JPanel contentPane;
      JMenuBar jMenuBar1 = new JMenuBar();
      JMenu jMenuFile = new JMenu();
      JMenuItem jMenuFileExit = new JMenuItem();
      JMenu jMenuHelp = new JMenu();
      JMenuItem jMenuHelpAbout = new JMenuItem();
      JToolBar jToolBar = new JToolBar();
      JButton jButton1 = new JButton();
      JButton jButton2 = new JButton();
      JButton jButton3 = new JButton();
      ImageIcon image1;
      ImageIcon image2;
      ImageIcon image3;
      JLabel statusBar = new JLabel();
      BorderLayout borderLayout1 = new BorderLayout();

      //Construct the frame
      public aaaFrame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception  {
        image1 = new ImageIcon(aaa.aaaFrame1.class.getResource("openFile.png"));
        image2 = new ImageIcon(aaa.aaaFrame1.class.getResource("closeFile.png"));
        image3 = new ImageIcon(aaa.aaaFrame1.class.getResource("help.png"));
        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 aaaFrame1_jMenuFileExit_ActionAdapter(this));
        jMenuHelp.setText("Help");
        jMenuHelpAbout.setText("About");
        jMenuHelpAbout.addActionListener(new aaaFrame1_jMenuHelpAbout_ActionAdapter(this));
        jButton1.setIcon(image1);
        jButton1.setToolTipText("Open File");
        jButton2.setIcon(image2);
        jButton2.setToolTipText("Close File");
        jButton3.setIcon(image3);
        jButton3.setToolTipText("Help");
        jToolBar.add(jButton1);
        jToolBar.add(jButton2);
        jToolBar.add(jButton3);
        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) {
        aaaFrame1_AboutBox dlg = new aaaFrame1_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);
        }
      }
    }

    class aaaFrame1_jMenuFileExit_ActionAdapter implements ActionListener {
      aaaFrame1 adaptee;

      aaaFrame1_jMenuFileExit_ActionAdapter(aaaFrame1 adaptee) {
        this.adaptee = adaptee;
      }
      public void actionPerformed(ActionEvent e) {
        adaptee.jMenuFileExit_actionPerformed(e);
      }
    }

    class aaaFrame1_jMenuHelpAbout_ActionAdapter implements ActionListener {
      aaaFrame1 adaptee;

      aaaFrame1_jMenuHelpAbout_ActionAdapter(aaaFrame1 adaptee) {
        this.adaptee = adaptee;
      }
      public void actionPerformed(ActionEvent e) {
        adaptee.jMenuHelpAbout_actionPerformed(e);
      }
    }

  • 相关阅读:
    注释
    选择器
    SQL语句中查找字符的位置
    SQL语句中截取字符串Substr
    IDENTITY(函数)
    SQL Server设置主键自增长列
    SQL语句操作ALTER
    表的主键
    南京夜市
    夜班
  • 原文地址:https://www.cnblogs.com/josn1984/p/369957.html
Copyright © 2020-2023  润新知