Salut,
J'ai un bout de code qui crée n boutons en fonction d'un argument lu sur la console, jusque la tout va.
J'aimerais qu'ils soient nommés du genre, bouton1, puis bouton2, ainsi de suite..
Code :
- // déclaration
- public static String btn_nom = "Bouton ";
- .....
- // main
- .....
- for (int i=0; i<j ; i++){
- int y = (35*i)+5;
- JButton btn_nom = new JButton ();
- fenetre.getContentPane().add(btn_nom);
- btn_nom.setBounds(60,y,120,30);
- }
|
Mais JButton() prends une string et non une variable, et .setTexte() marche pas non plus.
quelqu'un peut aiguiller, merci