点登录按钮后怎么做才能弹出另外一个界面窗口!
用主线程控制
eg:
public void jButton1_actionPerformed(ActionEvent e) {
try {
salary();
}
catch (SQLException ee) {
JOptionPane.showMessageDialog(null, "数据库连接失败,请确认数据库存在!", "错误",
JOptionPane.ERROR_MESSAGE);
}
}
public void salary() throws SQLException {
String zh, mm;
Connection con;
Statement sql;
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, "数据库连接失败,请确认数据库存在!", "错误",
JOptionPane.ERROR_MESSAGE);
}
try {
boolean panduan=true;
con = DriverManager.getConnection("jdbc:odbc:salary");
sql = con.createStatement();
rs = sql.executeQuery("select * from dl");
while (rs.next()) {
zh = rs.getString("zhanghao");
mm = rs.getString("mima");
if (zh.equals(jTextField1.getText()) &&mm.equals(jPasswordField1.getText()))
{ new startsf1() ;
this.setVisible(false) ;
panduan=false;
break;
}
}
if(panduan){
JOptionPane.showMessageDialog(null, "帐号或密码错误,请重新填写!", "错误",
JOptionPane.ERROR_MESSAGE);
}
}
catch(SQLException e){
JOptionPane.showMessageDialog(null, "数据库连接失败,请确认数据库存在!", "错误",
JOptionPane.ERROR_MESSAGE);
}
}
这是我毕设里做的得登陆界面得部分代码,希望对你有所帮助!