2010-03-13 11 views
0

Supposons que nous ayons un cadre nommé JFrame1 avec un attribut String nommé credentials initialisé à null. J'ai un jButton nommé button1 attaché au cadre et je veux changer l'attribut credentials de frame1 String en appuyant sur button1. J'ai besoin d'un conseil concernant le code ActionListener en particulier.Modifier l'attribut d'un cadre en appuyant sur un bouton

+0

Pouvez-vous poster un code que vous avez actuellement? –

Répondre

1
button.addActionListener(new ActionListener() { 
    public void actionPerformed(ActionEvent e) { 
     frame1.setUsername(..); 
    } 
}); 
Questions connexes