Friday, May 2, 2014

About JComboBox Java language?


I have to codes for JcomboBox
one is work well, while the other one didnt work at all
I tried a lot of times to figure why but I cant
please can any one help me!

JComboBox c1= (JComboBox)e.getSource();

String CPtype=(String)c1.getSelectedItem();

if (CPtype=="Canon 60D")
t2.setText("3800");
else if(CPtype=="Canon 70D")
t2.setText("4700");
else if(CPtype=="Canon EOS-M kit 22m")
t2.setText("1650");
else if(CPtype=="Nikon D3100")
t2.setText("1450");
else if(CPtype=="NikonD7100")
t2.setText("3700");
else if(CPtype=="Nikon D5300")
t2.setText("2850");
else
t2.setText("0");

JComboBox c2= (JComboBox)e.getSource();

String Ltype=(String)c2.getSelectedItem();

if (Ltype=="Canon EF 50mm")
t6.setText("3800");
else if(Ltype=="Canon EF 16-35mm")
t6.setText("4700");
else if(Ltype=="AF Nikkor 50mm f/1.8D")
t6.setText("1650");

Read more: About JComboBox Java language?