bonjour, j ai un ptit probleme pour imprimer
Je voudrais imprimer ma JOptionPane qui appartient à fenetre "fen1" (fenetre active) lorsque je clique sur le bouton imprimer. Mais le probleme, c'est que j'imprime la fenetre "ext".

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
 
class Extended extends JFrame
{
 
 String calcul = "calcul"; // Incrémentation de la donnée  
 String imprimer = "imprimer"; // Impression	
.......................;
    public Extended() 
	{
	super("Calcul de dallage par la methode élastique");
	 setResizable(false);
	GridBagLayout repartiteur = new GridBagLayout();
	GridBagConstraints contraintes;
             .....................
             }
 
public static void main(String [] args)
  {
    Extended ext = new Extended();
	ext.setVisible(true);// Affichage de la vue		  
  }	
 
private void  Fenetreresultat() {
 
	JFrame fen1 = new JFrame();
             fen1.setSize(840, 600);
             fen1.setTitle("Chargement");	
 
	GridBagLayout repartiteur = new GridBagLayout();
	GridBagConstraints contraintes;
	Container interieur = fen1.getContentPane();
	interieur.setLayout(repartiteur);
 
	JLabel Titre01=new JLabel("");		
	contraintes = new GridBagConstraints();
	contraintes.gridx = 1;
	contraintes.gridy = 0;
	Titre01.setPreferredSize(new Dimension(80, 15));
	Titre01.setMaximumSize(new Dimension(80, 15));
	Titre01.setMinimumSize(new Dimension(80, 15));
	contraintes.fill = GridBagConstraints.CENTER;
	repartiteur.setConstraints(Titre01, contraintes);
	interieur.add(Titre01);	
        .....................
  JButton impression = new JButton("IMPRESSION");
    contraintes = new GridBagConstraints();
    contraintes.gridx = 1;
    contraintes.gridy = NbPoint+13;
    contraintes.anchor = GridBagConstraints.CENTER;
    contraintes.insets = new Insets(10, 10, 10, 10);
    Color c=new Color(200, 200, 254);
    impression.setBackground(c);
    repartiteur.setConstraints(impression, contraintes);
    interieur.add(impression);
    impression.setActionCommand(imprimer);
    impression.addActionListener(controller);
 
   JOptionPane.showMessageDialog(null,interieur,"RESULTATS",JOptionPane.PLAIN_MESSAGE);
}
 
class Controller implements ActionListener {  
  public void actionPerformed(ActionEvent event)
    {
			    if (command == imprimer){
					Properties props = new Properties();
 
					props.put("awt.print.paperSize", "a4");
					props.put("awt.print.destination", "printer");
 
 
					PrintJob pJob = getToolkit().getPrintJob(Extended.this,"Printing_Test", props);
 
 
 
					if (pJob != null)
					{
						Graphics pg = pJob.getGraphics();
						printAll(pg);
						pg.dispose();
						pJob.end();	
					}
				}
}