Olá, tudo bem?
Sou novo nalinguagem JAVA. Estou fazendo umtrabalho para a faculdade no qual tenho q fazer uma interface para uma videolocadora, um um menu com aopção “Cadastrar”. Dentro desta opção, os subitems “filme” e gênero". Está retornando um erro. SEgue abaixo o código e o erro. Se algupem puder me ajudar…blz
import java.awt.<em>;
import java.awt.event.</em>;
import javax.swing.*;
public class GuiJVideoLoc extends JFrame{
private JLabel labelNomeFilme;
private JLabel labelGenero;
private JTextField tNomeFilme;
private JTextField tGenero;
private JPanel buttonJPanel;
private JButton buttons[] = new JButton[4];
private final String names[] = {"Salvar", "Editar", "Deletar", "Sair"};
public GuiJVideoLoc() {
super ("Interface para cadastro de Filmes");
JMenu menu = new JMenu ("Cadastrar");//cria o arquivo Cadastrar
menu.setMnemonic('C'); // configura o mnemônico com C
JMenuItem itemFilme = new JMenuItem ("Filme");
itemFilme.setMnemonic('F'); // configura o menmonico com F
menu.add(itemFilme); //adiciona o item filme ao menu Cadastrar
menu.addActionListener(
new ActionListener() { // AQUI É QUE GERA O ERRO NA COMPILAÇÃO ! ! !
public void ActionPerformed(ActionEvent event){
labelNomeFilme = new JLabel("Nome do Filme");
labelGenero = new JLabel("Genero");
tNomeFilme = new JTextField(30);
tGenero = new JTextField(30);
JPanel buttonJPanel = new JPanel(new GridLayout(0,4));
for (int count =0; count<buttons.length;count++){
buttons[count]=new JButton(names[count]);
buttonJPanel.add(buttons[count]);
}
JPanel labelPane = new JPanel(new GridLayout(0,1)); //cria JPanel dos labels
labelPane.add(labelNomeFilme);
labelPane.add(labelGenero);
JPanel fieldPane = new JPanel(new GridLayout(0,1)); //cria JPanels principal
fieldPane.add(tNomeFilme);
fieldPane.add(tGenero);
JPanel principalPane = new JPanel(new BorderLayout());
principalPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
principalPane.add(labelPane, BorderLayout.CENTER);
principalPane.add(fieldPane, BorderLayout.EAST);
principalPane.add(buttonJPanel, BorderLayout.SOUTH);
add(principalPane,BorderLayout.CENTER);
}
}
);
}
public static void main(String args[]){
GuiJVideoLoc videoloc = new GuiJVideoLoc();
videoloc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
videoloc.setSize(600,200);
videoloc.setVisible(true);
}
}
E ABAIXO O ERRO
C:\AD1>javac GuiJVideoLoc.java
GuiJVideoLoc.java:36: <anonymous GuiJVideoLoc$1> is not abstract and does not ov
erride abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.e
vent.ActionListener
new ActionListener() {
^
1 error
C:\AD1>
desde já, agradeço…