How can i use the selected item from combo box in if
statement (the combo box value is converted to string
), the java compiler shows an incompatible type error , saying string
cannot be converted to Boolean
. Please help :) Thank You in advance.
Code:
private void btnSignInActionPerformed(java.awt.event.ActionEvent evt) {
String userid = txtUserID.getText();
String username = txtUserName.getText();
String usertype = cmboUserType.getSelectedItem().toString();
DBConnector dbcon = new DBConnector();
dbcon.connect();
if(dbcon.isUserExists(userid, username,usertype)){
if (usertype = "Customer"){
msg.showMessageDialog(
this,
"Login Successful",
"Login Status",
1);
OrganicFoods.Customer cust = new OrganicFoods.Customer();
cust.setVisible(true);
}
else if ( usertype = "StoreAdmin"){
msg.showMessageDialog(
this,
"Login Successful",
"Login Status",
1);
OrganicFoods.StoreAdmin S1 = new OrganicFoods.StoreAdmin();
S1.setVisible(true);
}
else if ( usertype = "Collection_Delivery_Officer"){
msg.showMessageDialog(
this,
"Login Successful",
"Login Status",
1);
OrganicFoods.Collection_Delivery_Officer cdo1 = new OrganicFoods.Collection_Delivery_Officer();
cdo1.setVisible(true);
}
}else{
msg.showMessageDialog(
this,
"Login Failure",
"Login Status",
0);
}
}