So, I want to change the selected value of comboBox depending on values I read from my object. This is what I have so far:
public String[] waluta=new String[] {"EUR","PLN","USD"};
public GameEditFrame(int index) {
...
JComboBox walutaBox = new JComboBox(waluta);
String tmp=main.katalog.gra.get(index).cena.getWaluta();
if (tmp=="EUR" || tmp==null){
walutaBox.setSelectedItem(waluta[0]);
}else if (tmp=="PLN"){
walutaBox.setSelectedItem(waluta[1]);
}else if (tmp=="USD"){
walutaBox.setSelectedItem(waluta[2]);
}
...
}
Sadly, this is not working. Any ideas?
EDIT: SOLVED
Thanks to ZouZou and MadProgrammer comments I've modded previous code. Now it looks like this and it works fine:
public String[] waluta=new String[] {"EUR","PLN","USD"};
public GameEditFrame(int index) {
...
JComboBox walutaBox = new JComboBox(waluta);
String tmp=main.katalog.gra.get(index).cena.getWaluta();
if (tmp==null)
tmp="EUR";
walutaBox.setSelectedItem(tmp);
...
}