Java 加载窗口不';t出现

Java 加载窗口不';t出现,java,loading,jwindow,Java,Loading,Jwindow,我创建了一个加载窗口来加载数据库中的操作。现在我有一个问题,因为请求时窗口没有出现。 你能看到我的代码并帮助我吗 private void btCadastrarUsuarioActionPerformed(java.awt.event.ActionEvent evt) { LoadingWindow lw = new LoadingWindow(this); lw.sh

我创建了一个加载窗口来加载数据库中的操作。现在我有一个问题,因为请求时窗口没有出现。 你能看到我的代码并帮助我吗

private void btCadastrarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {                                                     
    LoadingWindow lw = new LoadingWindow(this);  
    lw.show(null,jpanel1);  

    if(confereSobrenome==true && confereEmail==true && confereSenha==true &&  
        confereNome==true && confereUser==true && confereSenhaConfirmacao==true){  


        FileInputStream fis;  
        if (fileFoto==null){  
            String path = this.getClass().getResource("/img/no_pic.jpg").getFile();  
            fileFoto=new File(path);  
        }  
        ImageIcon icone;  
        try {  
            Image image = ImageIO.read(fileFoto);  
            icone = new ImageIcon(image);  
        } catch (IOException ex) {  
            icone = new ImageIcon(getClass().getResource("/img/no_pic.jpg"));  
        }  

        icone.setDescription(fileFoto.getAbsolutePath());  
        UsuarioDao dao = new UsuarioDao();  
        if(btCadastrarUsuario.getText().equals("Atualizar")){  
            user.setFoto(icone);  
            dao.alteraUsuario(user);  
        }else{  
            Usuario user = new Usuario(txtUser.getText(), icone, txtPrimeiroNome.getText(), txtUltimoNome.getText(), new String (txtSenha.getPassword()), txtEmail.getText(),0,0);  
            dao.adicionaUsuario(user);              
        }  


        if(btCadastrarUsuario.getText().equals("Atualizar")){  
            btCadastrarUsuario.setText("Cadastrar");  
            CardLayout cards = (CardLayout)(jpPrincipal.getLayout());  
            cards.show(jpPrincipal, "apostas");              
            jLabel4.setIcon(new Util().dimencionaImagem(user.getFoto(),80));                      
        }else{  
            this.dispose();  
            BolaoFuleco.main(null);  

            newUser=false;  
            CardLayout cards = (CardLayout)(jpPrincipal.getLayout());  
            cards.show(jpPrincipal, "cadastro");                    
        }  




    }  
    try {  
        Thread.sleep(1300);  
    } catch (InterruptedException ex) {  
        Logger.getLogger(bolaoJFrame.class.getName()).log(Level.SEVERE, null, ex);  
    }  
    lw.close();  
} 
这里有LoadingWindow类:

public class LoadingWindow extends JWindow{  

public LoadingWindow(Frame owner) {  
    super(owner);  

    inicialize();  
}  


public void inicialize(){  
    setLayout(null);  

    //Util.centralizarJanela(this, 150, 150);  
    getContentPane().setBackground(Color.BLACK);  
    getContentPane().setLayout(new GridLayout(1,1));  
    JLabel imgLoading = new JLabel(new javax.swing.ImageIcon(getClass().getResource("/img/ipad_loading_40x40.gif")));  
    getContentPane().add(imgLoading);  
    //70% de transparência  
    AWTUtilities.setWindowOpacity(this, .8f);  
    setSize(50,50);  


}  

public void show(String texto, java.awt.Component componentOwner){  
    setLocationRelativeTo(componentOwner);  
    if(texto!=null){  
        getContentPane().setLayout(new GridLayout(2,1));  
        JLabel lbTexto = new JLabel(texto);  
        lbTexto.setForeground(Color.WHITE);  
        lbTexto.setFont(new java.awt.Font("Arial", 1, 12));   
        lbTexto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);  
        getContentPane().add(lbTexto);                 

    }  

    setVisible(true);  
}  

public void close(){  
    setVisible(false);  
    dispose();          
}  

public void noShow(){  
    setVisible(false);  
}      

}

您正在阻止事件调度线程,这意味着在您停止阻止之前,它无法处理您显示窗口的请求

考虑使用一种方法,在该方法中,您准备并显示窗口,启动worker,在它的
doInBackground
方法中,执行您需要执行的繁重任务,在
done
方法中,关闭窗口并通知您可能需要的任何人,以便继续执行您的程序

请查看以了解更多详细信息