difficultés avec JRadioButton
Bonjour !
Je veux avoir une popup avec une liste de choix dont un est sélectionné selon un prifl récupéré via le contrôleur.
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 33 34 35 36 37
| public class PopupOptionsSoldeFutur extends JPanel implements Cliquable {
private static JRadioButton[] choix = {
new JRadioButton("fin du mois"),
new JRadioButton("au plus bas"),
new JRadioButton("au plus haut"),
new JRadioButton("à la date : ")
};
Controleur c;
public PopupOptionsSoldeFutur(Controleur c) {
this.c = c;
GridBagLayout gbl = new GridBagLayout();
this.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
ButtonGroup bg = new ButtonGroup();
gbc.gridx = 0;
gbc.gridy = 0;
for (JRadioButton jrb : choix) {
this.add(jrb, gbc);
bg.add(jrb);
gbc.gridy++;
}
gbc.gridy --;
gbc.gridx++;
IntTextField jour = new IntTextField();
jour.setPreferredSize(new Dimension(70,20));
this.add(jour, gbc);
if (c.getInfosUtilisateur().getPreferencesSoldeFutur().getTypeOption() == TypeOption.LOW)
choix[1].isSelected();
else if (c.getInfosUtilisateur().getPreferencesSoldeFutur().getTypeOption() == TypeOption.HIGH)
choix[2].isSelected();
else if (c.getInfosUtilisateur().getPreferencesSoldeFutur().getDateOptionnelle() == 31)
choix[0].isSelected();
else {
choix[3].isSelected();
jour.setValue(c.getInfosUtilisateur().getPreferencesSoldeFutur().getDateOptionnelle());
}
} |
Problème : Aucun n'est sélectionné quand la popup s'affiche. Je fais quoi mal ?
Merci de votre aide :D