How to control another jframe buttons from login jframe..
try{
String sql = "SELECT * from tbluserlogin WHERE Name = '"+ txtusername.getText().toString()+"' AND Password= '"+txtpassword.getText()+"' AND Branch = '"+ CboDepartment.getSelectedItem().toString()+"' ";
pst = conn.prepareStatement(sql);
rs=pst.executeQuery(sql);
rs.next();
String name = rs.getString("Branch");
if (name.equals("Admin")) {
Main ah = new Main();
ah.setVisible(true);
this.dispose();
}
else if(name.equals("Minor Offense")){
new Main().setVisible(true);
this.dispose();
}
else if(name.equals("Traffic Branch")){
new Main().setVisible(true);
this.dispose();
}
else if(name.equals("Child @ Women Branch")){
new Main().setVisible(true);
this.dispose();
}
else if(name.equals("Crime Branch")){
new Main().setVisible(true);
this.dispose();
}
else {
JOptionPane.showMessageDialog(null, "Connot Login");
txtusername.setText("");
txtpassword.setText("");
CboDepartment.setSelectedIndex(-1);
}
}
catch (Exception e){
JOptionPane.showMessageDialog(null, e);
}