salut tout le monde
j'ai un problème avec la fermeture des fenetres
j'ai trois classe : classe1 , classe2 et classe3
je veux si je click sur la croix fermeture classe2 la fenetre classe1 ouvre et si je click sur fermeture classe 1 alors la fenetre classe3 ouvre
le problème avec passage entre classe 1 et classe3 , le problème si je click sur fermeture classe 1 alors la classe 3 n'ouvre pas
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 import javax.swing.SwingUtilities; import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JFrame; public class classe2 extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater(new Runnable() { public void run() { classe2 thisClass = new classe2(); thisClass.setVisible(true); } }); } /** * This is the default constructor */ public classe2() { super(); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(300, 200); this.setContentPane(getJContentPane()); this.setTitle("JFrame"); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { classe1 a = new classe1 (); a.setVisible(true); a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); a.setResizable (false); a.setLocationRelativeTo(null); setVisible(false); } }); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); } return jContentPane; } }
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 import javax.swing.SwingUtilities; import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JFrame; public class classe1 extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { classe1 thisClass = new classe1(); thisClass.setVisible(true); } }); } public classe1() { super(); initialize(); } private void initialize() { this.setSize(300, 200); this.setContentPane(getJContentPane()); this.setTitle("JFrame"); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { classe3 a = new classe3 (); a.setVisible(true); a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); a.setResizable (false); a.setLocationRelativeTo(null); setVisible(false);} }); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); } return jContentPane; } }
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
53
54
55
56
57
58
59 import javax.swing.SwingUtilities; import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JFrame; public class classe3 extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater(new Runnable() { public void run() { classe3 thisClass = new classe3(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.setVisible(true); } }); } /** * This is the default constructor */ public classe3() { super(); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(300, 200); this.setContentPane(getJContentPane()); this.setTitle("salut"); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); } return jContentPane; } }
Partager