⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frame1.java

📁 学生上机系统,请大家多多指教.以后会发
💻 JAVA
字号:
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.setBackground(Color.pink);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 36));    jLabel1.setText("欢迎登陆学生上机管理系统");    jLabel1.setBounds(new Rectangle(74, 41, 450, 80));    contentPane.setLayout(null);    this.setSize(new Dimension(600, 440));    this.setTitle("欢迎登陆上机卡管理系统");    jLabel2.setBackground(Color.pink);    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,"对不起,用户名和密码不能为空!!!","提示",JOptionPane.PLAIN_MESSAGE);      return;    }    ///////////上机卡管理员登陆    else if(user.equals("card_manager")&&password.equals("19850130"))    {        Frame2 frame=new Frame2();        frame.show(true);        this.show(false);    }    /////////////机房管理员登陆    else if(user.equals("computer_manager")&&password.equals("19850130"))    {       Frame3 frame=new Frame3();       frame.show(true);       this.show(false);    }    else    {      JOptionPane.showMessageDialog(this,"对不起,用户名或密码不正确!!!","提示",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);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -