P
P
Proffik2014-09-17 18:20:44
Java
Proffik, 2014-09-17 18:20:44

Why doesn't anonymous class work in java?

//add action listener for alpha
alpha.addActionListener(new ActionListener() {
public void actionPerfomend(ActionEvent ae){
lab.setText("Alpha button pressed");
}
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanKiLL, 2014-09-18
@Proffik

What exactly doesn't work? Have you looked in the debugger? Deliver banal System.out.println
Give more information.

//добавляем слушатель действий для альфа
alpha.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae){
        System.out.println("В аннонимом классе");
        lab.setText("Нажата кнопка Альфа");
    }
});

you also have a typo instead of actionPerfomend should beactionPerformed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question