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

📄 mainframe.java

📁 包含了7个java经典案例
💻 JAVA
字号:
package student;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class MainFrame extends JFrame {  JPanel contentPane;  JToolBar jToolBar1 = new JToolBar();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  JButton jButton3 = new JButton();  JButton jButton4 = new JButton();  BorderLayout borderLayout1 = new BorderLayout();  JPanel jPanel1 = new JPanel();  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel1 = new JLabel();  JButton jButton5 = new JButton();  JButton jButton6 = new JButton();  //Construct the frame  public MainFrame() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(borderLayout1);    this.setResizable(false);    this.setSize(new Dimension(641, 410));    this.setTitle("学生管理");    jButton1.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton1.setMaximumSize(new Dimension(79, 49));    jButton1.setMinimumSize(new Dimension(79, 49));    jButton1.setPreferredSize(new Dimension(79, 49));    jButton1.setMnemonic('0');    jButton1.setText("口令维护");    jButton1.addActionListener(new MainFrame_jButton1_actionAdapter(this));    contentPane.setToolTipText("");    jButton2.setText("成绩管理");    jButton2.addActionListener(new MainFrame_jButton2_actionAdapter(this));    jButton2.setMnemonic('0');    jButton2.setPreferredSize(new Dimension(79, 49));    jButton2.setActionCommand("成绩管理");    jButton2.setMinimumSize(new Dimension(79, 49));    jButton2.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton2.setMaximumSize(new Dimension(79, 49));    jButton3.setText("名单管理");    jButton3.addActionListener(new MainFrame_jButton3_actionAdapter(this));    jButton3.setMnemonic('0');    jButton3.setPreferredSize(new Dimension(79, 49));    jButton3.setActionCommand("学生管理");    jButton3.setMinimumSize(new Dimension(79, 49));    jButton3.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton3.setMaximumSize(new Dimension(79, 49));    jButton4.setText("基础设置");    jButton4.addActionListener(new MainFrame_jButton4_actionAdapter(this));    jButton4.setMnemonic('0');    jButton4.setPreferredSize(new Dimension(79, 49));    jButton4.setMinimumSize(new Dimension(79, 49));    jButton4.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton4.setMaximumSize(new Dimension(79, 49));    jPanel1.setBackground(SystemColor.inactiveCaption);    jPanel1.setLayout(xYLayout1);    jLabel1.setFont(new java.awt.Font("DialogInput", 1, 48));    jLabel1.setForeground(Color.yellow);    jLabel1.setRequestFocusEnabled(true);    jLabel1.setText("××学生成绩管理系统");    jButton5.setMaximumSize(new Dimension(79, 49));    jButton5.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton5.setMinimumSize(new Dimension(79, 49));    jButton5.setPreferredSize(new Dimension(79, 49));    jButton5.setMnemonic('0');    jButton5.setText("数据库管理");    jButton5.addActionListener(new MainFrame_jButton5_actionAdapter(this));    jButton6.setMaximumSize(new Dimension(79, 49));    jButton6.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton6.setMinimumSize(new Dimension(79, 49));    jButton6.setPreferredSize(new Dimension(79, 49));    jButton6.setMnemonic('0');    jButton6.setText("退出系统");    jButton6.addActionListener(new MainFrame_jButton6_actionAdapter(this));    contentPane.add(jToolBar1, BorderLayout.NORTH);    jToolBar1.add(jButton1, null);    jToolBar1.add(jButton2, null);    jToolBar1.add(jButton3, null);    jToolBar1.add(jButton4, null);    jToolBar1.add(jButton5, null);    jToolBar1.add(jButton6, null);    contentPane.add(jPanel1,  BorderLayout.CENTER);    jPanel1.add(jLabel1,    new XYConstraints(79, 92, 503, 149));  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void jButton1_actionPerformed(ActionEvent e) {    User_Dialog dlg = new User_Dialog();    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();  }  void jButton2_actionPerformed(ActionEvent e) {    Score_Dialog dlg = new Score_Dialog();    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();  }  void jButton3_actionPerformed(ActionEvent e) {    List_Dialog  dlg = new List_Dialog();    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();  }  void jButton4_actionPerformed(ActionEvent e) {    Base_Dialog  dlg = new Base_Dialog();    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();  }  void jButton5_actionPerformed(ActionEvent e) {    DB_Dialog  dlg = new DB_Dialog();    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();  }  void jButton6_actionPerformed(ActionEvent e) {    System.exit(0);  }}class MainFrame_jButton1_actionAdapter implements java.awt.event.ActionListener {  MainFrame adaptee;  MainFrame_jButton1_actionAdapter(MainFrame adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class MainFrame_jButton2_actionAdapter implements java.awt.event.ActionListener {  MainFrame adaptee;  MainFrame_jButton2_actionAdapter(MainFrame adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}class MainFrame_jButton3_actionAdapter implements java.awt.event.ActionListener {  MainFrame adaptee;  MainFrame_jButton3_actionAdapter(MainFrame adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton3_actionPerformed(e);  }}class MainFrame_jButton4_actionAdapter implements java.awt.event.ActionListener {  MainFrame adaptee;  MainFrame_jButton4_actionAdapter(MainFrame adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton4_actionPerformed(e);  }}class MainFrame_jButton5_actionAdapter implements java.awt.event.ActionListener {  MainFrame adaptee;  MainFrame_jButton5_actionAdapter(MainFrame adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton5_actionPerformed(e);  }}class MainFrame_jButton6_actionAdapter implements java.awt.event.ActionListener {  MainFrame adaptee;  MainFrame_jButton6_actionAdapter(MainFrame adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton6_actionPerformed(e);  }}

⌨️ 快捷键说明

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