Reputation:
I just want to compare two strings with each other in line 5 in the posted code but it says: Type mismatch: cannot convert from String to boolean.
but both of them are strings or strings in an array. What is the problem here? This is my Code:
final int ObjektlängeForActionListener = ProjektOBjektlängeGlobal;
comboBox_projekt.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
for(int key = 0; key < ObjektlängeForActionListener; key++){
if((String)comboBox_projekt.getSelectedItem().equals(Projektname0JSON[key])){
if(Verrechenbar0JSON[key] == "1"){
check_verrechenbar.setSelected(true);
}
if(Verrechenbar0JSON[key] == "0"){
check_verrechenbar.setSelected(false);
}
}
}
}
});
Thanks for the help beforehand :)
Upvotes: 1
Views: 464
Reputation: 69470
You cast the result of equals
to a String
. Remove the cast or cast comboBox_projekt.getSelectedItem()
to a String
if(comboBox_projekt.getSelectedItem().equals(Projektname0JSON[key])){
or
if(((String)comboBox_projekt.getSelectedItem()).equals(Projektname0JSON[key])){
Upvotes: 1