Quando chamo uma das minhas janelas o frame vem sem o conteudo interno estou usando o netbeans

6 respostas
B

Boa tarde galera sou iniciante no java e me deparei com um problema que não faço ideia do que seja
possuo uma Frame que ao clicar em um botão começa a rodar um processo ao fazer isso eu quero
abrir outra janela para que mostre carregando a janela esta pronta o problema é que quando chamo
a outra tela dentro do evento do botão ela aparece em branco sem os componentes internos neste caso
seriam duas jlabels.

O evento do botao seria:

private void jButtonImportarActionPerformed(java.awt.event.ActionEvent evt) {                                                
        Importe importe = new Importe();
        JFrameCarregando carregandoJFrame = new JFrameCarregando();
        if (!(diretorio == null)) {
            try {
                this.setVisible(false);
                carregandoJFrame.setVisible(true);
                importe.lerArquivo(diretorio);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "Arquivo não Selecionado");
        }
        carregandoJFrame.setVisible(false);
        this.setVisible(true);

    }

ja a outra tela seria:

import javax.swing.ImageIcon;

/**
 *
 * @author GTI
 */
public class JFrameCarregando extends javax.swing.JFrame {

    /**
     * Creates new form JFrameCarregando
     */
    public JFrameCarregando() {
        initComponents();
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jPanelCarregando = new javax.swing.JPanel();
        ImageIcon icon1 = new ImageIcon("src/logo.png");
        jLabelImagem2 = new javax.swing.JLabel(icon1);
        ImageIcon icon = new ImageIcon("src/carregando1.gif");
        jLabelCarregando = new javax.swing.JLabel(icon);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanelCarregando.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout jPanelCarregandoLayout = new javax.swing.GroupLayout(jPanelCarregando);
        jPanelCarregando.setLayout(jPanelCarregandoLayout);
        jPanelCarregandoLayout.setHorizontalGroup(
            jPanelCarregandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCarregandoLayout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(jLabelImagem2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
                .addComponent(jLabelCarregando, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(49, 49, 49))
        );
        jPanelCarregandoLayout.setVerticalGroup(
            jPanelCarregandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCarregandoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelCarregandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelImagem2, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                    .addComponent(jLabelCarregando, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 453, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanelCarregando, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 127, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanelCarregando, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

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

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JFrameCarregando.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JFrameCarregando.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JFrameCarregando.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JFrameCarregando.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JFrameCarregando().setVisible(true);
                
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabelCarregando;
    private javax.swing.JLabel jLabelImagem2;
    private javax.swing.JPanel jPanelCarregando;
    // End of variables declaration
}

Se souberem onde esta o erro vo ficar muito grato gente ja li varios foruns várias informações e não encontrei nada que me tirasse essa dúvida. Valeu.

6 Respostas

drsmachado

POR QUE VOCÊ ESTÁ GRITANDO? NÃO ENTENDE NADA DE INTERNET? COLOCAR CAIXA ALTA SIGNIFICA GRITAR.

B

Me desculpe mais se eu soubesse que isso iria chatear ou não seria de acordo eu não teria colocado
e obrigado pela dica e pela ajuda mesmo assim.

drsmachado

brluan:
Me desculpe mais se eu soubesse que isso iria chatear ou não seria de acordo eu não teria colocado
e obrigado pela dica e pela ajuda mesmo assim.

Na parte de cima do teu tópico original existe um botão chamado “Editar”. Clicando nele você consegue ter acesso à edição do título. Basta colocar de forma civilizada.

B

Gente não deixa meu tópico morrer :smiley:
preciso muito da ajuda de vocês se alguem
souber oque pode ser isso por favor me ajude.

E
jPanelCarregando = new javax.swing.JPanel();  
        ImageIcon icon1 = new ImageIcon("src/logo.png");  
        jLabelImagem2 = new javax.swing.JLabel(icon1);  
        ImageIcon icon = new ImageIcon("src/carregando1.gif");

Você está puxando os arquivos de imagens de src/ e esse diretório só existe dentro do seu Netbeans. Quando você for rodar esse programa esses arquivos não vão mais estar lá.

Você precisa procurar como é possível criar um ImageIcon que leia as imagens dentro do jar que você for criar.

B

Obrigado pela dica, mas tipo, mesmo eu rodando a aplicação ainda no netbeans a tela não deveria ser mostrada da maneira
correta? oque acontece é que no netbeans quando chega na hora que chama essa tela ela simplesmente vem vazia eu ainda
rodando interno,vlw.

Criado 12 de setembro de 2012
Ultima resposta 13 de set. de 2012
Respostas 6
Participantes 3