?? frame1.java~3~
字號(hào):
package student_computer;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JTextField jTextField1 = new JTextField(); JPasswordField jPasswordField1 = new JPasswordField(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); jLabel1.setFont(new java.awt.Font("Dialog", 0, 36)); jLabel1.setText("歡迎登陸學(xué)生上機(jī)管理系統(tǒng)"); jLabel1.setBounds(new Rectangle(74, 41, 450, 80)); contentPane.setLayout(null); this.setSize(new Dimension(601, 440)); this.setTitle("Frame Title"); jLabel2.setFont(new java.awt.Font("Dialog", 0, 16)); jLabel2.setText("用戶:"); jLabel2.setBounds(new Rectangle(318, 265, 68, 22)); jLabel3.setFont(new java.awt.Font("Dialog", 0, 16)); jLabel3.setText("密碼:"); jLabel3.setBounds(new Rectangle(318, 304, 68, 22)); jTextField1.setText(""); jTextField1.setBounds(new Rectangle(378, 265, 99, 24)); jPasswordField1.setText(""); jPasswordField1.setBounds(new Rectangle(378, 306, 99, 25)); jButton1.setBounds(new Rectangle(315, 357, 75, 25)); jButton1.setFont(new java.awt.Font("Dialog", 0, 16)); jButton1.setForeground(Color.black); jButton1.setText("登陸"); jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this)); jButton2.setBounds(new Rectangle(415, 357, 75, 25)); jButton2.setFont(new java.awt.Font("Dialog", 0, 16)); jButton2.setText("退出"); jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this)); contentPane.add(jLabel1, null); contentPane.add(jLabel2, null); contentPane.add(jLabel3, null); contentPane.add(jTextField1, null); contentPane.add(jPasswordField1, null); contentPane.add(jButton1, null); contentPane.add(jButton2, null); } //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) { String user=jTextField1.getText(); String password=jPasswordField1.getText(); /*try{ String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String dbURL = "jdbc:microsoft:sqlserver://210.30.104.11:1433; DatabaseName=DomitoryManagement"; String userName = "admin"; String userPwd = "gejingguo"; Class.forName(driverName); Connection con = DriverManager.getConnection(dbURL, userName, userPwd); //System.out.println(apartid+dom_id+date); PreparedStatement stmt=con.prepareStatement("select "); // stmt.setInt(1,apartid); }catch(Exception e1){e1.printStackTrace();}*/ if(user.equals("")||password.equals("")) { JOptionPane.showMessageDialog(this,"對(duì)不起,用戶名和密碼不能為空!!!","提示",JOptionPane.PLAIN_MESSAGE); return; } ///////////上機(jī)卡管理員登陸 else if(user.equals("card_manager")&&password.equals("19850130")) { } /////////////機(jī)房管理員登陸 else if(user.equals("student_manager")&&password.equals("19850130")) { } else { JOptionPane.showMessageDialog(this,"對(duì)不起,用戶名或密碼不正確!!!","提示",JOptionPane.PLAIN_MESSAGE); return; } } void jButton2_actionPerformed(ActionEvent e) { System.exit(1); }}class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jButton1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}class Frame1_jButton2_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jButton2_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton2_actionPerformed(e); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -