📄 mainwindow.java~9~
字号:
package sfms;import java.awt.*;import javax.swing.*;import java.awt.event.*;public class mainWindow extends JFrame implements ActionListener{JButton findSt,addSt,delSt,updateSt,exitB; public static void main (String args[]){ mainWindow frame=new mainWindow(); }//constructor public mainWindow(){ Container c=this.getContentPane(); c.setLayout(new GridLayout(2,1)); JPanel lowerPanel=new JPanel();//create label Font defaultFont=c.getFont(); JLabel label=new JLabel("欢迎进入资料档案管理系统"); label.setForeground(Color.blue); label.setFont(new Font("plain",Font.PLAIN,36)); c.add(label);//create Buttons for bottom panel findSt=new JButton("查询"); addSt=new JButton("添加"); delSt=new JButton("删除"); updateSt=new JButton("更新"); exitB=new JButton("退出");//add buttons lowerPanel.add(findSt); lowerPanel.add(addSt); lowerPanel.add(delSt); lowerPanel.add(updateSt); lowerPanel.add(exitB); c.add(lowerPanel);//register frame as listener for button events findSt.addActionListener(this); addSt.addActionListener(this); delSt.addActionListener(this); updateSt.addActionListener(this); exitB.addActionListener(this); this.setSize(400,300); this.setTitle("SFMS欢迎您"); this .setVisible(true);//create anonymous inner class to handle window closing event this.addWindowListener(new WindowAdapter(){ public void windoeClosing(WindowEvent event){ shutdown(); }}); }//actionPerformed is involked when a button is clicked public void actionPerformed(ActionEvent e){ if(e.getSource()==findSt){ findS(); } if(e.getSource()==addSt){ addS(); } if(e.getSource()==delSt){ delS(); } if(e.getSource()==updateSt){ updateS(); } if(e.getSource()==exitB){ shutdown(); } } private void findS(){ } private void addS(){ AddFI addFi=new AddFI(); addFi.setVisible(true); this.setVisible(false); } private void delS(){ } private void updateS(){ } private void shutdown(){ System.exit(0); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -