Salut,
Je voudrais fermer la fenêtre courante en affichant une autre
Cela ne marche pas avec
this.dispose();
this.hide();
this.setVisible(false);
Comment faire s'il vous plaît
Voici le code de ma classe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.awt.BorderLayout; 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Menu extends JFrame{
    private MenuDep menuDep = new MenuDep();
    private JButton bouton1 = new JButton("Interventions");
    private JButton bouton2 = new JButton("Références des cartouches");
    private JButton bouton3 = new JButton("Liste des départements");
    private JButton bouton4 = new JButton("Couleurs");
    private  JButton bouton5 = new JButton("Achat");
    public Menu(){
        this.setTitle("Menu");
        this.setSize(400, 400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setLayout(new BorderLayout());
        this.getContentPane().add(bouton1, BorderLayout.CENTER);
        this.getContentPane().add(bouton2, BorderLayout.NORTH);
        this.getContentPane().add(bouton3, BorderLayout.SOUTH);
        this.getContentPane().add(bouton4, BorderLayout.WEST);
        this.getContentPane().add(bouton5, BorderLayout.EAST);
        bouton3.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e){
 
                menuDep.show();
            }
        });
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setResizable(false);
        this.setVisible(true);
    }
}