views:

27

answers:

1

Suppose we have a JFrame named frame1 with a String attribute named credentials set inittially to null. I have a jButton named button1 attached to the frame and I want to change the frame1 String credentials attribute by pressing button1. I need some piece of advice regarding the ActionListener code especially.

+1  A: 
button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
         frame1.setUsername(..);
    }
});
Bozho