📄 mainframe.java~17~
字号:
package studentmanage;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <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; JMenuBar jMenuBar1 = new JMenuBar(); JMenu jMenuStudent = new JMenu(); JMenuItem jMenuStudentInsert = new JMenuItem(); JMenu jMenuHelp = new JMenu(); JMenuItem jMenuHelpAbout = new JMenuItem(); BorderLayout borderLayout1 = new BorderLayout(); JMenuItem jMenuStudentUpdate = new JMenuItem(); JMenuItem jMenuStudentQuery = new JMenuItem(); JLabel jLabel1 = new JLabel(); boolean status=false; //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.setSize(new Dimension(400, 300)); this.setTitle("学生信息管理系统"); jMenuStudent.setToolTipText(""); jMenuStudent.setText("学生信息管理"); jMenuStudentInsert.setText("学生信息录入"); jMenuStudentInsert.addActionListener(new MainFrame_jMenuStudentInsert_ActionAdapter(this)); jMenuHelp.setText("Help"); jMenuHelpAbout.setText("About"); jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(this)); jMenuStudentUpdate.setText("学生信息修改"); jMenuStudentUpdate.addActionListener(new MainFrame_jMenuStudentUpdate_actionAdapter(this)); jMenuStudentQuery.setText("学生信息查询"); jMenuStudentQuery.addActionListener(new MainFrame_jMenuStudentQuery_actionAdapter(this)); jLabel1.setFont(new java.awt.Font("Dialog", 0, 40)); jLabel1.setForeground(Color.red); jLabel1.setVerifyInputWhenFocusTarget(true); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setText("学生信息管理系统"); jMenuStudent.add(jMenuStudentInsert); jMenuStudent.add(jMenuStudentUpdate); jMenuStudent.add(jMenuStudentQuery); jMenuHelp.add(jMenuHelpAbout); jMenuBar1.add(jMenuStudent); jMenuBar1.add(jMenuHelp); contentPane.add(jLabel1, BorderLayout.CENTER); this.setJMenuBar(jMenuBar1); } public void jMenuStudentInsert_actionPerformed(ActionEvent e) { StudentInsertPanel si=new StudentInsertPanel(this); this.remove(this.getContentPane()); this.setContentPane(si); this.show(); } //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { } //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 jMenuStudentUpdate_actionPerformed(ActionEvent e) { StudentDialog s1=new StudentDialog(this,"学生信息修改",true); s1.setSize(320,250); s1.show(); if (this.status==true){ //找到对应的记录 this.status=false; StudentUpdatePanel su=new StudentUpdatePanel(this,s1.studentid,s1.name,s1.sex); this.remove(this.getContentPane()); this.setContentPane(su); this.show(); } } void jMenuStudentQuery_actionPerformed(ActionEvent e) { StudentDialog s1=new StudentDialog(this,"学生信息查询",true); s1.setSize(320,250); s1.show(); if (this.status==true){ //找到对应的记录 this.status=false; StudentQueryPanel su=new StudentQueryPanel(this,s1.studentid,s1.name,s1.sex); this.remove(this.getContentPane()); this.setContentPane(su); this.show(); } }}class MainFrame_jMenuStudentInsert_ActionAdapter implements ActionListener { MainFrame adaptee; MainFrame_jMenuStudentInsert_ActionAdapter( MainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuStudentInsert_actionPerformed(e); }}class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener { MainFrame adaptee; MainFrame_jMenuHelpAbout_ActionAdapter( MainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuHelpAbout_actionPerformed(e); }}class MainFrame_jMenuStudentUpdate_actionAdapter implements java.awt.event.ActionListener { MainFrame adaptee; MainFrame_jMenuStudentUpdate_actionAdapter(MainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuStudentUpdate_actionPerformed(e); }}class MainFrame_jMenuStudentQuery_actionAdapter implements java.awt.event.ActionListener { MainFrame adaptee; MainFrame_jMenuStudentQuery_actionAdapter(MainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuStudentQuery_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -