📄 mainframe.java~3~
字号:
package bar;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class mainFrame extends JFrame { JPanel contentPane; public int CardID; public boolean login = false; JMenuBar jMenuBar1 = new JMenuBar(); JMenu jMenuCard = new JMenu(); JMenuItem jMenuCardMoney = new JMenuItem(); JMenu jMenuHelp = new JMenu(); JMenuItem jMenuHelpAbout = new JMenuItem(); BorderLayout borderLayout1 = new BorderLayout(); JMenuItem jMenuCardQuery = new JMenuItem(); JMenu jMenuUse = new JMenu(); JMenuItem jMenuUseIn = new JMenuItem(); JMenuItem jMenuUseOut = new JMenuItem(); JMenu jMenuExit = new JMenu(); welcomePanel w1= new welcomePanel(); //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("欢迎光临"); jMenuCard.setText("查询"); jMenuCardMoney.addActionListener(new mainFrame_jMenuCardMoney_ActionAdapter(this)); jMenuHelp.setEnabled(false); jMenuHelp.setText("帮助"); jMenuHelpAbout.setText("关于"); jMenuHelpAbout.addActionListener(new mainFrame_jMenuHelpAbout_ActionAdapter(this)); jMenuCardMoney.setText("查询余额"); jMenuUse.setText("使用"); jMenuUseIn.setText("上机"); jMenuUseIn.addActionListener(new mainFrame_jMenuUseIn_actionAdapter(this)); jMenuUseOut.setText("下机"); jMenuUseOut.addActionListener(new mainFrame_jMenuUseOut_actionAdapter(this)); jMenuExit.setText("退出"); jMenuExit.addActionListener(new mainFrame_jMenuExit_actionAdapter(this)); jMenuCardQuery.setText("记录查询"); jMenuCardQuery.addActionListener(new mainFrame_jMenuCardQuery_actionAdapter(this)); jMenuCard.add(jMenuCardMoney); jMenuCard.add(jMenuCardQuery); jMenuHelp.add(jMenuHelpAbout); jMenuBar1.add(jMenuCard); jMenuBar1.add(jMenuUse); jMenuBar1.add(jMenuHelp); jMenuBar1.add(jMenuExit); jMenuUse.add(jMenuUseIn); jMenuUse.add(jMenuUseOut); this.setJMenuBar(jMenuBar1); this.setJMenuBar(jMenuBar1); this.getContentPane().add(w1,null); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { // jMenuCardMoney_actionPerformed(null); System.exit(0); } } public void jMenuCardMoney_actionPerformed(ActionEvent e) { loginDialog login1 = new loginDialog(this,"数据查询",true); login1.setSize(new Dimension(400, 300)); login1.show(); if(login==true){ CardMoneyPanel cardMoneyPanel1 = new CardMoneyPanel(this, CardID); this.remove(this.getContentPane()); this.setContentPane(cardMoneyPanel1); this.show(); }} //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { //定义对象 aboutDialog aD=new aboutDialog(); aD.setSize(new Dimension(400, 300)); aD.show(); } void jMenuCardQuery_actionPerformed(ActionEvent e) { loginDialog login1 = new loginDialog(this,"数据查询",true); login1.setSize(new Dimension(400, 300)); login1.show(); if(login){ cardQueryPanel cardQueryPanel1 = new cardQueryPanel(this, CardID); this.remove(this.getContentPane()); this.setContentPane(cardQueryPanel1); this.show(); } } void login_true(){ login = true; } void login_false(){ login = false; } void SetCardID(int cardID){ CardID = cardID; } void SetComputerID(int CID){ ComputerID = CID;} private int ComputerID; void jMenuUseIn_actionPerformed(ActionEvent e) { userInPanel useInPanel1 = new userInPanel(this); this.remove(this.getContentPane()); this.setContentPane(useInPanel1); useInPanel1.setSize(new Dimension(400, 300)); this.show(); } void jMenuUseOut_actionPerformed(ActionEvent e) { ComputerID = 0; useOutDialog useOutDialog1 = new useOutDialog(this, "欢迎再次光临", true); useOutDialog1.setSize(new Dimension(400, 300)); useOutDialog1.show(); if (ComputerID != 0) { outMoneyPanel outMoney1 = new outMoneyPanel(ComputerID); this.remove(this.getContentPane()); this.setContentPane(outMoney1); this.show(); } } void jMenuExit_actionPerformed(ActionEvent e) { System.exit(0); }}class mainFrame_jMenuCardMoney_ActionAdapter implements ActionListener { mainFrame adaptee; mainFrame_jMenuCardMoney_ActionAdapter(mainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuCardMoney_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_jMenuCardQuery_actionAdapter implements java.awt.event.ActionListener { mainFrame adaptee; mainFrame_jMenuCardQuery_actionAdapter(mainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuCardQuery_actionPerformed(e); }}class mainFrame_jMenuUseIn_actionAdapter implements java.awt.event.ActionListener { mainFrame adaptee; mainFrame_jMenuUseIn_actionAdapter(mainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuUseIn_actionPerformed(e); }}class mainFrame_jMenuUseOut_actionAdapter implements java.awt.event.ActionListener { mainFrame adaptee; mainFrame_jMenuUseOut_actionAdapter(mainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuUseOut_actionPerformed(e); }}class mainFrame_jMenuExit_actionAdapter implements java.awt.event.ActionListener { mainFrame adaptee; mainFrame_jMenuExit_actionAdapter(mainFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuExit_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -