Forums Register Login

help!! on dynamic select box - 2

+Pie Number of slices to send: Send
hi,
Thanks for the reply. I implemented the logic , but it doesnot seem to work.
I am pasting the code below for ur perusal.
Thank you once again.
regards,
ganesh.
public class HelloWorld2 extends JApplet implements ActionListener {

Frame a = new Frame("Deembed");
String data_a[] = { "a" , "b" , "c" };
String data_b[] = { "d" , "e" , "f" };
String data_c[] = { "x" , "y", "z" };
String data[] = { "trans" , "ind" , "cap" };
JComboBox CB2 = new JComboBox(data_a);
public void init()
{
JComboBox CB1 = new JComboBox(data);



this.getContentPane().add(CB1);
this.getContentPane().add(CB2);
this.getContentPane().setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e) {

JComboBox cb = (JComboBox)e.getSource();
String data = (String)cb.getSelectedItem();
//process : Add data to CB2
if(data == "ind") {
CB2.removeAllItems();
CB2.addItem(data_b);
}
else if (data== "cap"){
CB2.removeAllItems();
CB2.addItem(data_c);
}
}
}
+Pie Number of slices to send: Send
I think you may want to do the String comparison using equals() rather than '==', eg. data.equals("ind").
You will probably want another 'else' for when the combo selection goes back to "a".
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 844 times.
Similar Threads
state of radio button.
help on dynamic select box
Problem adjusting JScrollPane programatically
help!!! java.security.access controlException
Event-handling Problem in 3-JComboBox and 1-JTable Search Program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:21:53.