Erro ao abrir janela

2 respostas
WGuedes

Olá pessoal,

Estou fazendo um sistema de cadastrar e listar livros, porém o mesmo está com erro no construtor:

CadLivro.JAVA

private void ListLivroActionPerformed(java.awt.event.ActionEvent evt) {                                          

        new [b]ListLivro[/b](listaLivros).setVisible(true);
    }

construtor da classe Livro.JAVA

public Livro(String t, Long l, String editora, int ano, int numPaginas, LinkedList<Autor> autores) { super(t, l); this.editora = editora; this.ano = ano; this.numPaginas = numPaginas; this.autores = autores; }

o erro é no ListLivro, mas a classe está dentro do pacote.

2 Respostas

discorpio

Boa tarde WGuedes.

Será que é possível pelo menos voce colocar o código da classe ListLivro :?:

Assim fica díficil do Brasil ganhar de 5 x 0 da Coréia do Norte.

Coloca o código ai para que possamos te ajudar.

WGuedes

Olá, desculpe o erro:

Classe Livro

package biblioteca;
import java.io.Serializable;

import java.util.LinkedList;
import pessoa.Autor;
public class Livro extends Acervo implements Serializable{

    private String editora;
    private int ano;
    private int numPaginas;
    private LinkedList<Autor> autores;


public Livro(){}


    public Livro(String t, Long l, String editora, int ano, int numPaginas, LinkedList<Autor> autores) {
        super(t, l);
        this.editora = editora;
        this.ano = ano;
        this.numPaginas = numPaginas;
        this.autores = autores;
    }

    public int getAno() {
        return ano;
    }

    public void setAno(int ano) {
        this.ano = ano;
    }

    public LinkedList<Autor> getAutores() {
        return autores;
    }

    public void setAutores(LinkedList<Autor> autores) {
        this.autores = autores;
    }

    public String getEditora() {
        return editora;
    }

    public void setEditora(String editora) {
        this.editora = editora;
    }

    public int getNumPaginas() {
        return numPaginas;
    }

    public void setNumPaginas(int numPaginas) {
        this.numPaginas = numPaginas;
    }

    
public String toString(){
        String aux = " ";
        if (autores != null )
        for (Autor aut:autores){
            aux = aux + aut.toString() + "\n";
        }
        return editora + " " + ano + " " + numPaginas + " " + aux + super.toString();
   }
    
}

a interface para listar e cadastrar, lembrando que somente o listar livro (ListLivro) não funciona.

Menu.JAVA

package gui;

import biblioteca.*;
import pessoa.*;
import java.util.*;
import conexoes.*;


public class Menu extends javax.swing.JFrame {

    /** Creates new form Menu */
    public Menu() {
        initComponents();
        /*Arquivo a = new Arquivo ("Colecao.txt");
        a.abreArquivo("Read");
        listaLivros =(LinkedList<Livro>) a.leRegistro();
        a.fechaArquivo();*/
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        MnuSair = new javax.swing.JMenuItem();
        cadAutor = new javax.swing.JMenu();
        mnuC = new javax.swing.JMenuItem();
        cadLivro = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        listAutor = new javax.swing.JMenuItem();
        ListLivro = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenu1.setMnemonic('a');
        jMenu1.setText("Arquivo");

        MnuSair.setMnemonic('s');
        MnuSair.setText("Sair");
        MnuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MnuSairActionPerformed(evt);
            }
        });
        jMenu1.add(MnuSair);

        jMenuBar1.add(jMenu1);

        cadAutor.setMnemonic('o');
        cadAutor.setText("Cadastrar");

        mnuC.setText("Autor");
        mnuC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuCActionPerformed(evt);
            }
        });
        cadAutor.add(mnuC);

        cadLivro.setText("Livro");
        cadLivro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadLivroActionPerformed(evt);
            }
        });
        cadAutor.add(cadLivro);

        jMenuBar1.add(cadAutor);

        jMenu3.setMnemonic('o');
        jMenu3.setText("Listar");
        jMenu3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu3ActionPerformed(evt);
            }
        });

        listAutor.setText("Autor");
        listAutor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listAutorActionPerformed(evt);
            }
        });
        jMenu3.add(listAutor);

        ListLivro.setText("Livro");
        ListLivro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListLivroActionPerformed(evt);
            }
        });
        jMenu3.add(ListLivro);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                        

    private void MnuSairActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        Arquivo a = new Arquivo("Colecao.txt");
        a.abreArquivo("write");//Abre para escrever arquivo
        a.gravaRegistro(listaLivros);
        a.fechaArquivo();
        System.exit(0);
}                                       

    private void mnuCActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
       new CadAutor(listaAutores).setVisible(true);
    }                                    

    private void cadLivroActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        new CadLivro(listaLivros).setVisible(true);
}                                        

    private void listAutorActionPerformed(java.awt.event.ActionEvent evt) {                                          
        new ListAutor(listaAutores).setVisible(true);        // TODO add your handling code here:
    }                                         

    private void ListLivroActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
[b][i][u]        new ListLivro(listaLivros).setVisible(true);[/b][/i][/u]
    }                                         

    private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
    }                                      

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Menu().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JMenuItem ListLivro;
    private javax.swing.JMenuItem MnuSair;
    private javax.swing.JMenu cadAutor;
    private javax.swing.JMenuItem cadLivro;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem listAutor;
    private javax.swing.JMenuItem mnuC;
    // End of variables declaration                   
 private LinkedList<Autor> listaAutores = new LinkedList<Autor>();
 private LinkedList<Livro> listaLivros = new LinkedList<Livro>();
}
Criado 15 de junho de 2010
Ultima resposta 15 de jun. de 2010
Respostas 2
Participantes 2