Je suis coincé avec un nouveau problème, ne sais pas si cela fonctionne mais ici j'ai la liste de JCombobox
comme suit.Comment donner deux formulaires à JCombobox Articles en Java Swing
JCombobox comboBox = new JComboBox();
comboBox.addItem("UserName");
comboBox.addItem("Password");
comboBox.addItem("DLNo 20 b");
comboBox.addItem("DLNo 20 b");
Je veux imprimer ma base de données column names
qui sont plus de 40! Lorsque je sélectionne le Combobox
, il doit imprimer en interne mon article personnalisé ici.
Ici j'ai essayé avec ce code, mais je ne suis pas satisfait de cette
if(comboBox.getSelectedIndex()==0)
{
System.out.println("U_NAME");
}
if(comboBox.getSelectedIndex()==1)
{
System.out.println("P_NAME");
}
if(comboBox.getSelectedIndex()==2)
{
System.out.println("DL_NO_20_b");
}
if(comboBox.getSelectedIndex()==3)
{
System.out.println("DL_NO_20_b");
}
est-il une meilleure façon de venir sur cela, comme mapping objects
utilisez ItemListener pour unique selectedItem, ActionListener pour chaque sélection – mKorbel