How to close one Jinternalframe when opening another?

Asked

Viewed 68 times

0

Hi guys I’m developing a project for my course, and when I click on the menu to open a new JInternalFrame, the same opens "below" of the other already opened.
I would like to know how to open it "on top" of the already open? follows the code:

public class Inicial extends javax.swing.JFrame {

Connection conexao = null;
PreparedStatement pst = null;
ResultSet rs = null;
Cadastro cadastro = new Cadastro();
Relatorio relatorio = new Relatorio();
EditarExcluir editarExcluir = new EditarExcluir();

public Inicial() {
    initComponents();
    conexao = ModuloConexao.conector();
    System.out.println(conexao);
}
private void menuCadastrarActionPerformed(java.awt.event.ActionEvent evt) {                                              


    cadastro.setVisible(true);
    desktop.add(cadastro);


}                                             

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

    relatorio.setVisible(true);
    desktop.add(relatorio);

}                                             

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

    editarExcluir.setVisible(true);
    desktop.add(editarExcluir);


}                                                 

1 answer

0

Leave for instance them within the action of the button, who knows this help. Remembering that because it is a Jinternalframe can use the .show

Ex:

    private void menuRelatorioActionPerformed(java.awt.event.ActionEvent evt) {                                              
         Relatorio relatorio = new Relatorio();
         desktop.add(relatorio);
         relatorio.show();

    }     

Browser other questions tagged

You are not signed in. Login or sign up in order to post.