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
| public class Impression {
PrinterJob printer;
public void printList(int selectedIndex){
printer = PrinterJob.getPrinterJob();
// printer.setPrintable(new Printer(option));
printer.setPrintable(new Printer());
printer.setJobName("liste des eleves ");
if(!printer.printDialog()){
return;
}
try{
printer.setCopies(12);
printer.print();
}catch(Exception ex){
System.out.println(ex.getMessage());
}
}
public class Printer implements Printable {
public Printer() {
}
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
if(pageIndex > 0)
return (NO_SUCH_PAGE);
Graphics2D g2d = (Graphics2D)graphics;
Font titleF = new Font("Goudy Old Style", Font.BOLD, 17);
Font valueF = new Font("Goudy Old Style", Font.PLAIN, 14);
Color Blue = new Color(26,175,228);
//ImageIcon icon = new ImageIcon(getClass().getResource("/images/logo_uds.JPG"));
g2d.rotate(-Math.PI/24);
g2d.drawImage(icon.getImage(), 3, 15, null);
g2d.rotate(Math.PI/24);
GradientPaint gp = new GradientPaint(150, 100, Blue, 70, 70, Color.LIGHT_GRAY);
g2d.setPaint(gp);
g2d.setFont(new Font("Goudy Old Style", Font.PLAIN, 36));
g2d.drawString("LYCEE TECHNIQUE DE GALIM", 50, 50);
g2d.setFont(titleF);
g2d.drawString(" Liste Des Eleves de la "+infoClassSelected, 10, 150);
g2d.drawString("Année scolaire:", 10, 175);
g2d.drawString("Enseignants :", 10, 200);
g2d.setColor(Color.BLACK);
g2d.setFont(valueF);
jtable.print(g2d) //mon tableur qui contient plus de 60 lignes
return PAGE_EXISTS;
}
}
} |
Partager