求助!做了一个登录界面,在此基础上怎样通过验证输入的信息连接Mysql?
程序代码:
import javax.swing.*; import java.awt.*; import java.sql.*; import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Student extends JFrame{ JLabel jlname = new JLabel("姓名 :"); static JTextField jtname= new JTextField(); JLabel jlpass = new JLabel("学号 :"); static JTextField jtpass =new JTextField(); static JButton jblogin = new JButton("登录"); static JButton jbreset =new JButton("重置"); public Student(String s){ super(s); this.setLayout(null); jlname.setBounds(new Rectangle(20,30,60,30)); jtname.setBounds(new Rectangle(80,30,180,30)); jlpass.setBounds(new Rectangle(20,80,50,30)); jtpass.setBounds(new Rectangle(80,80,180,30)); jblogin.setBounds(new Rectangle(80,120,80,30)); jbreset.setBounds(new Rectangle(170,120,80,30)); this.add(jlname); this.add(jtname); this.add(jlpass); this.add(jtpass); this.add(jblogin); this.add(jbreset); this.setSize(355,254); this.setResizable(false); this.setVisible(true); } public static void main(String [] a){ final Student nuex =new Student("学生信息管理系统"); jblogin.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ methodA(); } }); jbreset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { methodB(); } }); nuex.addWindowListener(new WindowAdapter(){ public void windowClosing (WindowEvent e){ System.exit(0); } }); } public static void methodA(){ JDialog d=new JDialog(); JLabel c= new JLabel("登录成功",JLabel.CENTER); d.add(c); d.setSize(200,200); d.setVisible(true); } public static void methodB(){ jtname.setText(""); jtpass.setText(""); } }