I would like to know how to link JComboBox to Lists, java.awt.List? When I select France, for example, to show me l2 from the list java.awt.List ! Can someone help me? Here is my code:
JPanel p1 = new JPanel();
//p1.setLayout(null); (see my photo)not function good
p1.setLayout(null); (see my photo) are using Layout Null
JComboBox<String> cb = new JComboBox<>();
cb.setBounds(0,0,160,25);
cb.addItem("Austria");
cb.addItem("France");
p1.add(cb);
cb.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent arg0) {
int selectedIndex = cb.getSelectedIndex(); not help me
}
});
List l1 = new List();
l1.add("Text1");
l1.add("Text2");
List l2 = new List();
l2.add("Text1");
l2.add("Text2");
Each country has its list by numbered it. example France = l2 I want when I select France to list my l2. I would like an example as a solution if possible.
I want to answer someone who knows not beginners in Java.
Using Layout enter image description here
Not using Layout
What I want is this! I select Romania and this list appears to me! enter image description here
All of the examples here are useless. That's why I need someone who knows.