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
|
class Extended extends JFrame
{
JFrame fen2 = new JFrame();
public Extended(){
//remplissage et affichage de la fenetre "ext"
//remplissage et affichage de fen2
......
}
public static void main(String [] args){
Extended ext = new Extended();
ext.setVisible(true);// Affichage de la vue
}
private void Imprimer(){
JobAttributes ja = new JobAttributes();
ja.setDestination(JobAttributes.DestinationType.PRINTER);
PageAttributes pa = new PageAttributes();
pa.setMedia(PageAttributes.MediaType.A4);
pa.setOrientationRequested(PageAttributes.OrientationRequestedType. LANDSCAPE);
PrintJob pj = getToolkit().getPrintJob(Extended.this,"Printing_Test", ja, pa);
if (pj != null){
Graphics pg = pj.getGraphics();
printAll(pg);
pg.dispose();
pj.end();
}
Printer();
}
} |
Partager