At first I am beginner in Java. I have problem with checkstyle error mentioned in thread title.
Consider having similiar code:
public class myClass {
JButton[] buttons;
public myClass() {
this.buttons = new JButton[2];
//constructor code....
this.buttons[0].addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
firstMethod(0, 1);
secondMethod(5, 10);
}
});
}
public void firstMethod( int x, int y ) {
// do something
}
public void secondMethod( int x, int y ) {
// do something
}
}
In constructior I've created onclick event for button from attribute buttons, where when the button is clicked it will perform method firstMethod(int, int) and secondMethod(int, int), everything working of course, but the checkstyle throws me the error.
For some reasons I cannot just use this.firstMethod() as I am inside another object (ActionListener).
Any ideas how to throw myClass reference into actionListener?