运行出来点登录按钮没有反应,是我的代码有问题吗
package frame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
public class LoginFrame extends JFrame implements ActionListener {
JTextField userName,passWord;
JLabel name,psw,tip;
Box boxHOne,boxHTwo,boxVOne,boxVTwo;
JButton logIn,signUp;
public LoginFrame(){
setTitle("推箱子");
setLayout(new FlowLayout());
boxHOne=Box.createHorizontalBox();
boxVOne=Box.createVerticalBox();
boxVTwo=Box.createVerticalBox();
name=new JLabel("用户名:");
psw=new JLabel("密码");
boxVOne.add(name);
boxVOne.add(psw);
userName=new JTextField(15);
passWord=new JTextField(15);
boxVTwo.add(userName);
boxVTwo.add(passWord);
boxHOne.add(boxVOne);
boxHOne.add(Box.createHorizontalStrut(10));
boxHOne.add(boxVTwo);
logIn=new JButton("登录");
logIn.addActionListener(this::actionPerformed);
signUp=new JButton("注册");
signUp.addActionListener(this::actionPerformed);
boxHTwo=Box.createHorizontalBox();
boxHTwo.add(logIn);
boxHTwo.add(signUp);
add(boxHOne);
add(boxHTwo);
setBounds(1100,500,320,200);
setVisible(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==logIn)
dataQuery();
else if(e.getSource()==signUp)
new SignUpFrame();
}
public void dataQuery(){
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("com.mysql.jdbc.driver");
}catch (Exception e){}
try{
String uri="jdbc:mysql://localhost:3306/pushBox?useSSL=true";
String user="root";
String password="123456";
con= DriverManager.getConnection(uri,user,password);
sql=con.createStatement();
String uName=userName.getText();
rs=sql.executeQuery("SELECT *FROM user WHERE username="+uName);
String pasw=passWord.getText();
String pasw1=rs.getString("password");
do{
if(rs==null){
tip=new JLabel("用户名不存在");
add(tip);
}
else {
if(pasw==pasw1){
new MainFrame();
break;
}
else{
tip=new JLabel("密码错误");
add(tip);
}
}
}while(rs==null||pasw!=pasw1);
con.close();
}catch (SQLException e){}
}
public static void main(String args[]){
new LoginFrame();
}
}