µ±Ç°Î»ÖãºÊ×Ò³ > ¿Î³ÌÉè¼ÆÑ¡Ìâ¹ÜÀíϵͳ
½Ìʦ½çÃæ£º
class teachermainframe extends JPanel implements ActionListener { static final int WIDTH = 1000; static final int HETGHT = 500; private JFrame usermainframe; private JMenu timu,xuanti,xuesheng, help,quanxian; private JMenuItem studentadd,helpa, timuadd,timuchange,timudelete,timusearch,xueshengsearch,xuantiqueren,xuantisearch; public void add(Component c, GridBagConstraints constraints, int x, int y, int w, int h) { constraints.gridx = x; constraints.gridy = y; constraints.gridwidth = w; constraints.gridheight = h; add(c, constraints); } public teachermainframe() { Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); int width = screenSize.width; int height = screenSize.height; int x = (width - WIDTH) / 2; int y = (height - HETGHT) / 2; usermainframe = new JFrame(\Ñ¡Ìâ¹ÜÀíϵͳ---\ usermainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout lay = new GridBagLayout(); setLayout(lay); usermainframe.add(this, BorderLayout.WEST);
9
about,
usermainframe.setSize(1000, 500); usermainframe.setLocation(x, y); usermainframe.setResizable(false); usermainframe.setVisible(true); String path = \
ImageIcon background = new ImageIcon(path); JLabel label = new JLabel(background);
label.setBounds(0, 0, usermainframe.getWidth(), usermainframe.getHeight());
JPanel imagePanel = (JPanel) usermainframe.getContentPane(); imagePanel.setOpaque(false);
usermainframe.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE)); JPanel contentPane = new JPanel() { public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setFont(new Font(\»ªÎÄÐп¬\ g2.shear(0.0, 00.0); g2.drawString(\½Ìʦ½çÃæ---\ } };
usermainframe.add(contentPane);
JMenuBar menubar = new JMenuBar(); usermainframe.setJMenuBar(menubar); timu = new JMenu(\ÌâÄ¿¹ÜÀí\xuesheng = new JMenu(\ѧÉú¹ÜÀí\xuanti = new JMenu(\Ñ¡Ìâ¹ÜÀí\help = new JMenu(\°ïÖú\quanxian = new JMenu(\ȨÏÞ\about = new JMenuItem(\¹ØÓÚ\helpa = new JMenuItem(\°ïÖúÊÖ²á\timuadd = new JMenuItem(\ÌâÄ¿Ìí¼Ó\timuchange = new JMenuItem(\ÌâÄ¿ÐÞ¸Ä\timudelete = new JMenuItem(\ÌâĿɾ³ý\timusearch = new JMenuItem(\ÌâÄ¿²éѯ\xueshengsearch = new JMenuItem(\ѧÉú²éѯ\xuantiqueren=new JMenuItem(\Ñ¡ÌâÈ·ÈÏ\xuantisearch=new JMenuItem(\Ñ¡Ìâ²éѯ\studentadd = new JMenuItem(\Ìí¼ÓÓû§\menubar.add(timu); menubar.add(xuesheng); menubar.add(xuanti); menubar.add(help); menubar.add(quanxian); quanxian.add(studentadd);
10
}
timu.add(timuadd); timu.add(timuchange); timu.add(timudelete); timu.add(timusearch);
xuesheng.add(xueshengsearch); xuanti.add(xuantiqueren); xuanti.add(xuantisearch); help.add(helpa); help.add(about);
helpa.addActionListener(this); about.addActionListener(this);
xueshengsearch.addActionListener(this); timuadd.addActionListener(this); timuchange.addActionListener(this); timudelete.addActionListener(this); timusearch.addActionListener(this); xuantiqueren.addActionListener(this); xuantisearch.addActionListener(this); studentadd.addActionListener(this);
½ÌʦÌâÄ¿¹ÜÀí½çÃæ£º
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == about) { String message = \ ¿Î³ÌÉè¼ÆÑ¡Ìâ¹ÜÀíϵͳ V1.0 °æ \ JOptionPane.showMessageDialog(null, message); } else if (source == helpa) { String message = \ °ïÖú¹¦ÄÜ´ýÐø... \ JOptionPane.showMessageDialog(null, message); }else if (source == studentadd) {
11
}
}
yonghuaddframe main=new yonghuaddframe(); }else if (source == xueshengsearch) { String sql=\¶þ°à'and major='¼ÆËã»úϵ'\ studentinformationframe main=new studentinformationframe(sql);
}else if (source == timuadd||source ==timuchange||source ==timudelete||source ==timusearch) { String sql=\ timuinformationframe main=new timuinformationframe(sql); }else if (source == xuantiqueren) { timuqurenframe main=new timuqurenframe(); }else if (source == xuantisearch) { timusearchframe main=new timusearchframe(); }
ѧÉú¹ÜÀí½çÃæ£º
12
¹²·ÖÏí92ƪÏà¹ØÎĵµ