Bonjour,
Je voudrais fermer une fenêtre avec un bouton que j'appelle jExit... Sachant que cette fenêtre n'est pas ma fenêtre principale, et que je ne veux pas que cliquer sur le bouton jExit me ferme toute mon application, mais juste la fenêtre secondaire...
Mon code :
C'est au niveau du this.setVisible(false) et du this.dispose() que ça ne veut pas fonctionner...
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public class ResultFrame extends JFrame { private JPanel jContentPane = null; private JButton jExit = null; public ResultFrame (){ super("Result"); Application monApplication = new Application(); appli = monApplication; initialize(); } private void initialize() { this.setSize(300,200); this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); this.setVisible(true); this.setResizable(false); this.setContentPane(getJContentPane()); } private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); jContentPane.add(getJExit(), BorderLayout.SOUTH); } return jContentPane; } private JButton getJExit() { if (jExit == null) { jExit = new JButton(); jExit.setText("Exit"); jExit.setPreferredSize(new Dimension(75, 26)); jExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if(e.getSource()==jExit){ this.setVisible(false); this.dispose(); } } }); } return jExit; } }
Si vous pouviez m'aider, ça serait sympa ! Merci d'avance !
Partager