I created a java application where login credentials are required to have access.
I recorded the information about username in ArrayList
.
private void jBLoginActionPerformed(java.awt.event.ActionEvent evt) {
String sql="select * from logins where username=? and password=? and idTypeLogin=?";
try{
pst=(PreparedStatement) conexao.prepareStatement(sql);
pst.setString(1, jTUser.getText());
pst.setString(2, jPass.getText());
pst.setString(3, jComboBoxTipoLogin.getSelectedItem().toString());
rs=pst.executeQuery();
if(rs.next()){
String idTypeLogin= rs.getString("idTypeLogin");
if (idTypeLogin.equals("Administrator")) {
jTTaskAdmin ah = new jTTaskAdmin();
ah.setVisible(true);
}
else {
jTTaskTecnic eh = new jTTaskTecnic();
eh.setVisible(true);
}
this.setVisible(false);
}
else{
JOptionPane.showMessageDialog(null, "User Invalid");
}
//close();
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
List<String> loggedInUsers = new ArrayList<String>();
loggedInUsers.add(jTUser.getText())
List<String> t = loggedInUsers;
jTTasktecnic.recordVar=loggedInUsers.get(0);
}
And I add this code in second form
static String recordVar;
How can I do to get the information that was recorded in the array, but in another form. That is, I recorded the information in ArrayList
in the Login form, now I want to get this information in another form.
How can I do this?
Thank you