JComboBox ne se remplit pas
Bonjour J'ai plusieurs element dans une fenetre : Jlabel, JcomboBox
Je recupere des données dans une base de données, une valeur par JLabel, et une liste pour ma ComboBox.
les Label, ok
Mais Les combos, restent vide. sachant que je teste bien ma liste... elle n'est pas vide.
Comme si elle etait re-initialisée par la suite.
Classe construisant la Frame
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public abstract class AbstractElectionsForm extends javax.swing.JFrame {
protected javax.swing.JLabel jLabelSAP;
protected javax.swing.JLabel jLabelSeuilElec;
protected javax.swing.JComboBox<String> jComboBoxNomListe;
private static final long serialVersionUID = 1L;
public AbstractElectionsForm() {
initComponents();
}
private void initComponents() {
jLabelSAP = new javax.swing.JLabel(); // se remplissent nickel
jLabelSeuilElec = new javax.swing.JLabel(); // se remplissent nickel
jComboBoxNomListe = new javax.swing.JComboBox<String>(); // Ne se remplit pas
} |
Classe chargée d'initialiser les element Jlabel, JCombo....
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| public class ElectionSwing extends AbstractElectionsForm implements IUiElections{
@Autowired
private IElectionsMetier metier;
List<ListeElectorale> listes = new ArrayList<ListeElectorale>();
public void init()
{
super.init();
String info;
try{
listes = metier.getListeElectorale();
for(ListeElectorale ls : listes) {
jComboBoxNomListe.addItem(ls.getNom());
System.out.println((ls.getNom())
);
}
}
catch(Exception e)
{
System.out.println("Error"
);
}
int nbSap = metier.getNbSiegesAPourvoir();
double seuil = metier.getSeuilElectoral();
jLabelSAP.setText(jLabelSAP.getText() + " " + Integer.toString(nbSap));
jLabelSeuilElec.setText(jLabelSeuilElec.getText() + " " + Double.toString(seuil) +" %");
//On desactice certains liens
} |
Si vous avez besoin de plus d'infos dites moi, merci