Boa Tarde galera sou novo no java e novo no fórum estou com o seguinte problema
em um determinado momento na minha aplicação dentro de uma janela aciono um botão
o evento deste botão seria chamar outra tela, ele chama a tela no entanto ela vem sem seus
componentes apenas aparece em branco.
Código do evento do botão:
private void jButtonImportarActionPerformed(java.awt.event.ActionEvent evt) {
Importe importe = new Importe();
//nova janela que irá abrir com o evento do botão
JFrameCarregando carregandoJFrame = new JFrameCarregando();
if (!(diretorio == null)) {
try {
this.setVisible(false);
carregandoJFrame.setVisible(true);
//importe apenas um evento executado também ao se apertar o botão
importe.lerArquivo(diretorio);
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(rootPane, "Arquivo não Selecionado");
}
carregandoJFrame.setVisible(false);
this.setVisible(true);
}
O código da Janela que deveria ser aberta segue:
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
}
Obrigado a todos.