Bonjour,
Debutant en JAVA et après avoir consulté des dizaines de pages sur l'impression dans ce language je n'ai toujours pas compris comment effectuer l'impression de ma JFrame car il n'y a AUCUNE véritable explication dans ses pseudo "tutoriels", je m'en remet donc a vous

Je voudrais pouvoir imprimer cette JFrame (ou plutot ce qu'elle contient) au lancement du programme donc sans bouton n'y quoi que ce soit histoire que je comprenne comment sa marche, merci d'avance.

PS : inutile de me renvoyer à http://bruno-richeton.developpez.com...?page=sommaire, ce tuto n'explique rien.

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
 
 
 
public class NewClass extends JFrame {
 
    private JLabel lkPrenom;
    private JLabel lkNom;
    private JLabel lkProfession;
    private JLabel lkAdr;
    private JLabel lkCP;
    private JLabel lkVille;
    private JLabel lkTel;
    private JLabel lkNumk;
    private JLabel lPatient;
    private JLabel lMedecin;
    private JLabel lDDP;
    private JLabel lNDSE;
    private JLabel lDM;
    private JTextField tfPatient;
    private JTextField tfMedecin;
    private JTextField tfDDP;
    private JTextField tfNDSE;
    private JTextArea taDM;
 
 
 
 
    public NewClass(String nomFenetre){
        super(nomFenetre);
        this.setBounds(30, 30, 700, 1000);
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        //Label
        lkNom = new JLabel("nom");
        lkPrenom = new JLabel("prenom");
        lkProfession = new JLabel("proffesion");
        lkAdr = new JLabel("adresse");
        lkCP = new JLabel("CP");
        lkVille = new JLabel("Ville");
        lkTel = new JLabel("08 25 25 25 25");
        lkNumk = new JLabel("25 022254 7");
        lPatient = new JLabel("PATIENT : ");
        lMedecin = new JLabel("MEDECIN : ");
        lDDP = new JLabel("Date de prescription : ");
        lNDSE = new JLabel("Nombre de séance effectuées : ");
        lDM = new JLabel("Diagnostic médical : ");
        //TextField
        tfPatient = new JTextField(15);
        tfMedecin = new JTextField(15);
        tfDDP = new JTextField(5);
        tfNDSE = new JTextField(5);
        //TextArea
        taDM = new JTextArea(4,63);
        this.fenetrePrincipale();
        this.setResizable(false);
        this.setVisible(true);
    }
 
    private void fenetrePrincipale(){
 
        Container c = getContentPane();
 
        //Panel Prenom et nom
        JPanel pPrenomNom = new JPanel();
        pPrenomNom.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pPrenomNom.add(lkPrenom);
        pPrenomNom.add(lkNom);
        //Panel Proffession
        JPanel pProfession = new JPanel();
        pProfession.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pProfession.add(lkProfession);
        //Panel Adresse
        JPanel pAdr = new JPanel();
        pAdr.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pAdr.add(lkAdr);
        //Panel CP et Ville
        JPanel pCPVille = new JPanel();
        pCPVille.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pCPVille.add(lkCP);
        pCPVille.add(lkVille);
        //Panel Tel
        JPanel pTel = new JPanel();
        pTel.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pTel.add(lkTel);
        //Panel NumK
        JPanel pNumK = new JPanel();
        pNumK.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pNumK.add(lkNumk);
        //Panel GridLayout for Entete Evelyne(pE1)
        JPanel pE1 = new JPanel();
        pE1.setLayout(new GridLayout(6,1));
        pE1.add(pPrenomNom);
        pE1.add(pProfession);
        pE1.add(pAdr);
        pE1.add(pCPVille);
        pE1.add(pTel);
        pE1.add(pNumK);
        //
        //Panel Patient
        JPanel pPatient = new JPanel();
        pPatient.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pPatient.add(lPatient);
        pPatient.add(tfPatient);
        //Panel Medecin
        JPanel pMedecin = new JPanel();
        pMedecin.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pMedecin.add(lMedecin);
        pMedecin.add(tfMedecin);
        //Panel GridLayout for Patient et Medecin(pE2)
        JPanel pE2 = new JPanel();
        pE2.setLayout(new GridLayout(2,1));
        pE2.add(pPatient);
        pE2.add(pMedecin);
        //
        //Panel Contenant pE1 et pE2
        JPanel pPE1PE2 = new JPanel();
        pPE1PE2.setLayout(new GridLayout(1,2,110,50));
        pPE1PE2.add(pE1);
        pPE1PE2.add(pE2);
        //
        //
        //Panel DDP
        JPanel pDDP = new JPanel();
        pDDP.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pDDP.add(lDDP);
        pDDP.add(tfDDP);
        //Panel NDSE
        JPanel pNDSE = new JPanel();
        pNDSE.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pNDSE.add(lNDSE);
        pNDSE.add(tfNDSE);
        //
        //Panel GridLayout contenant pDDP et pNDSE(E3)
        JPanel pE3 = new JPanel();
        pE3.setLayout(new GridLayout(1,2,100,50));
        pE3.add(pDDP);
        pE3.add(pNDSE);
        //
        //
        //Panels pour Diagnostic medical pDM1 et pDM2
        JPanel pDM1 = new JPanel();
        pDM1.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pDM1.add(lDM);
        JPanel pDM2 = new JPanel();
        pDM2.setLayout(new FlowLayout(FlowLayout.LEFT,1,1));
        pDM2.add(taDM);
        //
        //Panel BorderLayout pDM contenant pDM1 et pDM2
        JPanel pDM = new JPanel();
        pDM.setLayout(new BorderLayout());
        pDM.add(pDM1,BorderLayout.NORTH);
        pDM.add(pDM2,BorderLayout.CENTER);
        //
        //
        //Panel Borderlayout Contenant ALLN  :
        JPanel ALLN = new JPanel();
        ALLN.setLayout(new BorderLayout(0,10));
        ALLN.add(pPE1PE2,BorderLayout.NORTH);
        ALLN.add(pE3,BorderLayout.CENTER);
        ALLN.add(pDM,BorderLayout.SOUTH);
        //
        //
        //
 
 
        // Panel contenant TT :
        JPanel ALL = new JPanel();
        ALL.setLayout(new BorderLayout());
        ALL.add(ALLN,BorderLayout.NORTH);
 
        c.add(ALL);
        c.setVisible(true);
 
 
    }
 
 
 
 
    public static void main(String[] args){
 
        NewClass e = new NewClass("uneFenetre");
 
 
 
 
 
 
    }
}