Boa Tarde Galera estou com o seguinte problema possuo uma
Frame principal que ao clicar em um botão chamado “Importe” é lançado um evento
que chama outra frame chamada “JFrameCarregando” ao chamar essa tela oque acontece
é que ela vem sem seu conteudo interno oque não entendo o porquê reparei que em outro
botao que chama uma JFileChooser caso eu não chame esse seletor de arquivo a tela me
aparece perfeita não sei oque pode ser isto, segue os codigos:
Codigo da Tela Principal - Botao IMPORTE:
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);
// this.dispose();
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 {
// carregandoJFrame.setVisible(true);
JOptionPane.showMessageDialog(rootPane, "Arquivo não Selecionado");
}
carregandoJFrame.setVisible(false);
this.setVisible(true);
}
Tela-Principal Botao “Selecionar” :
private void jButtonSelecionarArquivoActionPerformed(java.awt.event.ActionEvent evt) {
jFileChooser.setVisible(true);
jPanelTelaPrincipal.setVisible(false);
jButtonCancelar.setVisible(false);
jButtonImportar.setVisible(false);
jButtonSelecionarArquivo.setVisible(false);
jLabelImagem1.setVisible(false);
jLabelDiretorio.setVisible(false);
}
Tela-Principal Evento do Seletor de Arquivos:
private void jFileChooserActionPerformed(java.awt.event.ActionEvent evt) {
try {
int returnVal = jFileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
diretorio = jFileChooser.getSelectedFile().getAbsolutePath();
jLabelDiretorio.setText(diretorio);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
jPanelTelaPrincipal.setVisible(true);
jButtonCancelar.setVisible(true);
jButtonImportar.setVisible(true);
jButtonSelecionarArquivo.setVisible(true);
jLabelImagem1.setVisible(true);
jLabelDiretorio.setVisible(true);
}
Codigo da Frame Carregando segunda frame que vem em branco:
package com.gti.DGRS.visao;
import javax.swing.ImageIcon;
/**
*
* @author GTI
*/
public class JFrameCarregando extends javax.swing.JFrame {
/**
* Creates new form JFrameCarregando
*/
public JFrameCarregando() {
initComponents();
setLocationRelativeTo(null);
ImageIcon icon = new ImageIcon("src/logo.png");
setIconImage(icon.getImage());
}
/**
* 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(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCarregandoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelCarregandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabelImagem2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jLabelCarregando, javax.swing.GroupLayout.Alignment.LEADING, 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
}
Gente caso precise de mais partes do código pra entender o problema ou algum esclarecimento sobre algo que fiz to por aqui
só perguntar, me ajudem por favor, dês de já agradeço.