Bonsoir,
J'ai ces code là:
Est-ce que au au lieu de cre rune classe "Dialog" qui herite de JDialog, ont aurait pu crée rune variable "private" de type Doalog a l'interieur de cette classe ? comme ceci:
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 import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; public class Dialog extends JDialog{ public Dialog(){ super(); JPanel panel=new JPanel(); panel.add(new JLabel("Hello dialog")); this.getContentPane().add(panel); } public Dialog(MainFrame mf,String title,boolean modal){ super(mf,title,modal); this.setSize(300,200); JPanel panel=new JPanel(); panel.add(new JLabel("Hello dialog")); this.getContentPane().add(panel); this.setVisible(true); } }
Possible ? Je pense que oui.
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 import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; public class Dialog { Private JDialog MaDialog; public Dialog(){ MaDialog = new JDialog(); MaDialog.setTitle("...."); etc... etc... MaDialog.setVisible("True"); } etc...
Partager