Mon problème est le suivant... J'ais un groupe de bouton Radion qui suivant le bouton selectionné affiche une autre liste juste a coté d'autres boutons radio. Je n'arrive pas a rafraichir mon affichage. Je vous montre le code pour mieux m'expliquer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 // Associate the two buttons with a button group ButtonGroup group = new ButtonGroup(); group.add(_b1); group.add(_b2); group.add(_b3); group.add(_b4); group.add(_b5); _jpfonct.add(_b1); _jpfonct.add(_b2); _jpfonct.add(_b3); _jpfonct.add(_b4); _jpfonct.add(_b5); _b1.addActionListener(this); _b2.addActionListener(this); _b3.addActionListener(this); _b4.addActionListener(this); _b5.addActionListener(this);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 public void actionPerformed(ActionEvent e) { if (_b1.equals(e.getSource())) { _panelfonct=_init; _panelfonct.repaint(); _nom = "Arithmétique"; JRadioButton b1 = new JRadioButton("Addition"); JRadioButton b2 = new JRadioButton("Soustraction"); JRadioButton b3 = new JRadioButton("Multiplication"); JRadioButton b4 = new JRadioButton("Division"); JRadioButton b5 = new JRadioButton("Arrondi"); JRadioButton b6 = new JRadioButton("Partie Entière"); JRadioButton b7 = new JRadioButton("Entier supérieur"); JRadioButton b8 = new JRadioButton("Valeur Absolue"); JRadioButton b9 = new JRadioButton("Signe"); JRadioButton b10 = new JRadioButton("Puissance"); JRadioButton b11 = new JRadioButton("Modulo"); JRadioButton b12 = new JRadioButton("Racine Carrée"); _panelfonct.setLayout(new GridLayout(12,1)); ButtonGroup group1 = new ButtonGroup(); group1.add(b1); group1.add(b2); group1.add(b3); group1.add(b4); group1.add(b5); group1.add(b6); group1.add(b7); group1.add(b8); group1.add(b9); group1.add(b10); group1.add(b11); group1.add(b12); _panelfonct.add(b1); _panelfonct.add(b2); _panelfonct.add(b3); _panelfonct.add(b4); _panelfonct.add(b6); _panelfonct.add(b7); _panelfonct.add(b8); _panelfonct.add(b9); _panelfonct.add(b10); _panelfonct.add(b11); _panelfonct.add(b12); _jpnom.add(_panelfonct); } else if (_b2.equals(e.getSource())) { _panelfonct=_init; _panelfonct.repaint(); _nom = "Texte"; JRadioButton b1 = new JRadioButton("Concaténation"); JRadioButton b2 = new JRadioButton("Longueur"); JRadioButton b3 = new JRadioButton("Extraction"); JRadioButton b4 = new JRadioButton("Position"); JRadioButton b5 = new JRadioButton("Suppression des espaces à gauche"); JRadioButton b6 = new JRadioButton("Suppression des espaces à droite"); _panelfonct.setLayout(new GridLayout(6,1)); ButtonGroup group1 = new ButtonGroup(); group1.add(b1); group1.add(b2); group1.add(b3); group1.add(b4); group1.add(b5); group1.add(b6); _panelfonct.add(b1); _panelfonct.add(b2); _panelfonct.add(b3); _panelfonct.add(b4); _panelfonct.add(b6); _jpnom.add(_panelfonct); } else if (_b3.equals(e.getSource())) { _panelfonct=_init; _panelfonct.repaint(); _nom = "Conversion"; JRadioButton b1 = new JRadioButton("Majuscule"); JRadioButton b2 = new JRadioButton("Minuscule"); JRadioButton b3 = new JRadioButton("Texte"); JRadioButton b4 = new JRadioButton("Numérique"); JRadioButton b5 = new JRadioButton("Code ASCII en caractère"); JRadioButton b6 = new JRadioButton("Caractère en code ASCII"); _panelfonct.setLayout(new GridLayout(6,1)); ButtonGroup group1 = new ButtonGroup(); group1.add(b1); group1.add(b2); group1.add(b3); group1.add(b4); group1.add(b5); group1.add(b6); _panelfonct.add(b1); _panelfonct.add(b2); _panelfonct.add(b3); _panelfonct.add(b4); _panelfonct.add(b6); _jpnom.add(_panelfonct); } else if (_b4.equals(e.getSource())) { _panelfonct=_init; _panelfonct.repaint(); _nom = "Conditionnelle"; JRadioButton b1 = new JRadioButton("Condition sur NULL"); JRadioButton b2 = new JRadioButton("Première valeur non NULL" + "(Nombre de valeur **)"); JRadioButton b3 = new JRadioButton("Dans le cas" + "(Nombre de cas **)"); _panelfonct.setLayout(new GridLayout(5,1)); ButtonGroup group1 = new ButtonGroup(); group1.add(b1); group1.add(b2); group1.add(b3); _panelfonct.add(b1); _panelfonct.add(b2); _panelfonct.add(b3); _jpnom.add(_panelfonct); } else if (_b5.equals(e.getSource())) { _panelfonct=_init; _panelfonct.repaint(); _nom = "Groupe"; JRadioButton b1 = new JRadioButton("Moyenne"); JRadioButton b2 = new JRadioButton("Somme"); JRadioButton b3 = new JRadioButton("Minimum"); JRadioButton b4 = new JRadioButton("Maximum"); JRadioButton b5 = new JRadioButton("Nombre"); JRadioButton b6 = new JRadioButton("Nombre Distinct"); _panelfonct.setLayout(new GridLayout(6,1)); ButtonGroup group1 = new ButtonGroup(); group1.add(b1); group1.add(b2); group1.add(b3); group1.add(b4); group1.add(b5); group1.add(b6); _panelfonct.add(b1); _panelfonct.add(b2); _panelfonct.add(b3); _panelfonct.add(b4); _panelfonct.add(b6); _jpnom.add(_panelfonct); } }
Si quelqu'un peut m'aider, son aide sera le bien venu... D'avance Merci
Avec ce code, j'ais en fait les boutons radio qui s'ajoute dans mon panel au fur et a mesure... Il ne s'effacent plus... admetons que j'ais 2 boutons radio : arithmétique et texte. lorsque je clique sur arithmétique, je voi a coté apparaitre des boutons radio comme addition, soustraction, ... Je clique alors sur le bouton radio texte... et cette foi ci je devrais voir : concaténation, longueur, ... hors je vois tous les radio d'arithmétique + tous les radio de texte... j'espère que vous comprenez mieux ce que je veux dire...
Partager