这是我的代码。
private void btnloginActionPerformed(java.awt.event.ActionEvent evt) {
String username = "";
String sql = "select * from userinfo where uname=? and pword=?";
try{
pst = conn.prepareStatement(sql);
pst.setString(1, txt_username.getText());
pst.setString(2, txt_password.getText());
rs=pst.executeQuery();
if(rs.next()){
afterLogin pwcorrect = new afterLogin();
pwcorrect.setVisible(true);
this.setVisible(false);
username = txt_username.getText();
}
else{
JOptionPane.showMessageDialog(null, "Username and Password are Incorrect.");
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
我需要从另一个类访问用户名的值。有什么办法吗???请帮我写代码。