⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logindemo1.java~3~

📁 该文件中包含有源代码及一部分的文档,该系统是一个小型的英语单词字典的系统.
💻 JAVA~3~
字号:
package logindemo;

import java.awt.Toolkit;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Dimension;
import javax.swing.JMenuItem;
import java.awt.event.ActionEvent;
import javax.swing.JMenuBar;
import java.awt.event.MouseAdapter;
import javax.swing.JMenu;
import javax.swing.JPanel;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class LoginDemo1 {
    boolean packFrame = false;

    /**
     * Construct and show the application.
     */
    public LoginDemo1() {
        LoginFrame1 frame = new LoginFrame1();
        // Validate frames that have preset sizes
        // Pack frames that have useful preferred size info, e.g. from their layout
        if (packFrame) {
            frame.pack();
        } else {
            frame.validate();
        }

        // Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
    }



    /**
     * Application entry point.
     *
     * @param args String[]
     */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.
                                             getSystemLookAndFeelClassName());
                } catch (Exception exception) {
                    exception.printStackTrace();
                }

                new LoginDemo1();
            }
        });
    }

    void createMenu() {

         JMenuBar menuBar = new JMenuBar();
            setJMenuBar(menuBar);
            menu=new JMenu("查询");
            menuBar.add(menu);
            menuItem=new JMenuItem("按书名查询");
            menuItem.addActionListener(new MenuActionListenerClass(this));
            menuItem.setActionCommand("按书名查询");
            menu.add(menuItem);
            menuItem=new JMenuItem("按作者查询");
            menuItem.addActionListener(new MenuActionListenerClass(this));
            menuItem.setActionCommand("按作者查询");
            menu.add(menuItem);
            menuItem=new JMenuItem("按出版社查询");
            menuItem.addActionListener(new MenuActionListenerClass(this));
            menuItem.setActionCommand("按出版查询");
            menu.add(menuItem);
            menuItem=new JMenuItem("按类别查询");
            menuItem.addActionListener(new MenuActionListenerClass(this));
            menuItem.setActionCommand("按类别查询");
            menu.add(menuItem);

     }

     /**
      * Component initialization.
      *
      * @throws java.lang.Exception
      */
     private void jbInit() throws Exception {
         contentPane = (JPanel) getContentPane();
         contentPane.setLayout(borderLayout1);
         setSize(new Dimension(400, 300));
         createMenu();
         setTitle("欢迎进入图书查询系统");
     }

    public void MenuActionPerformed(ActionEvent e) {
    if ("确定".equals(e.getActionCommand())) {
      System.exit(0);
    }
    else if ("取消".equals(e.getActionCommand())) {
      System.exit(0);
    }
  }
  class MenuActionListenerClass implements ActionListener {
    MainDemoframe1 frame;
    public MenuActionListenerClass(MainDemoframe1 frame) {
      this.frame = frame;
    }
    public void actionPerformed(ActionEvent e) {
      frame.MenuActionPerformed(e);
    }
}
    class PopupListener extends MouseAdapter {
      MainDemoframe1 frame;
      public PopupListener(MainDemoframe1 frame) {
        this.frame = frame;
      }
      public void mousePressed(MouseEvent e) {
        maybeShowPopup(e);
      }
      public void mouseReleased(MouseEvent e) {
        maybeShowPopup(e);
      }
      private void maybeShowPopup(MouseEvent e) {
        if (e.isPopupTrigger()) {
          frame.popup.show(e.getComponent(), e.getX(), e.getY());
        }
      }
}

    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -