Prezados,
utilizo a IDE Eclipse para desenvolver os meus códigos em java. Porém, estou começando a utilizar métodos com eventos e, como no código descrito abaixo, quando utilizo o “new ActionListener()” ou qualquer outro evento, como o MouseListener(), me é apresentado o erro “ActionListener cannot be resolved to a type”.
Busquei em diversos sites e em diversas mensagens neste fórum e não encontrei um Norte para chegar a solução do problema. Alguém poderia me ajudar nisso?
Obrigado.
package md.orcamento;
import java.awt.Event.*;
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class framePrincipal extends JFrame {
Container cp;
private JPanel PPrincipal;
private JPanel PTitulo;
private JLabel LTitulo;
private JButton BInsert;
private JButton BSelect;
private JButton BDelete;
public framePrincipal() {
this.setTitle("Orçamento");
this.setSize(300,100);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.getContentPane().setLayout(new BorderLayout());
JPanel PPrincipal = new JPanel();
JPanel PTitulo = new JPanel();
JLabel LTitulo = new JLabel("ORÇAMENTO");
JButton BInsert = new JButton("Novo");
JButton BSelect = new JButton("Consulta");
JButton BDelete = new JButton("Exclui");
PTitulo.add(LTitulo);
PPrincipal.add(BInsert);
PPrincipal.add(BSelect);
PPrincipal.add(BDelete);
cp = getContentPane();
cp.add(PTitulo,BorderLayout.NORTH);
cp.add(PPrincipal,BorderLayout.CENTER);
BInsert.setEnabled(false);
BInsert.addActionListener (
new ActionListener(){ //O erro aparece nessa linha
public void actionPerformed(ActionEvent event){
//nop
}
}
);
}
public static void main (String args[]) {
new framePrincipal().show();
}
}