I have a class that extends a JPanel
, in this JPanel
I add a JButton
and I use the addActionListener
method to set a ActionListener
to that JButton
, but when I'm creating ActionListener
I can not access the attributes of JPanel
, follow the code below:
public class MemoriaView extends JPanel {
private GenericAPI api;
private JButton salvar;
public MemoriaView(){
super();
this.setLayout(new MigLayout());
this.setSize(500,600);
this.api = new GenericAPI<MemoriaModel>();
this.salvar = new JButton("Salvar");
this.salvar.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
/* Aqui quero pode acessar o this.api porem nao consigo */
}
});
}