| 12
 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
 
 |  
try 
{
      //Création du printerJob
      PrinterJob job = PrinterJob.getPrinterJob();
      //Creation du format des pages
      PageFormat pop  = job.defaultPage();
      //mise en paysage
      pop.setOrientation(PageFormat.LANDSCAPE);
      //Création du Book
      Book book = new Book();
      //Boucle d'ajout des impressions des tableaux pour chaque objet
      for(int i =0; i < MyArrayList.size();i++)
      {
 
            //AJOUT DU PREMIER TABLEAUX:
            //Création du modele
            TBH = new TableModelHisto(2);
            //Ajout des infos au modele
            TBH.AjoutsInfos((MyObj)MyArrayList.get(i), 1,getDateHisto().getDate());
            //Creation de l'entete de la page d'impression
            headerFormat = new MessageFormat("Traitement 1 Element n°"+((MyObj)MyArrayList.get(i)).getId());
            //Création du pide de page de la page d'impression
            footerFormat = new MessageFormat("Page {0}");
            //Ajout du contenu à la page d'impression (recupération de l'image du tableaux)
            printable = TabHisto.getPrintable(JTable.PrintMode.FIT_WIDTH,headerFormat,footerFormat);
            //Ajout de la page au livre
            book.append(printable, pop);
 
            //AJOUT DU DEUXIEME TABLEAUX : MEME OPERATION
            //Les données sont définies par le modèle
            TBH = new TableModelHisto(2);
            getTabHisto().setModel(TBH);
            TBH.AjoutsInfos((MyObj)MyArrayList.get(i), 2,getDateHisto().getDate());
             headerFormat = new MessageFormat("Traitement 2 Element n°"+((MyObj)MyArrayList.get(i)).getId());
             footerFormat = new MessageFormat("Page {0}");
             printable =    TabHisto.getPrintable(JTable.PrintMode.FIT_WIDTH,headerFormat,footerFormat);
             book.append(printable, pop);
 
      }
      //Attribution du book au PrinterJob
      job.setPageable(book);
      //Affichage de la boite de dialogue d'impression
      boolean printAccepted = job.printDialog();
      //Si l'impression n'est pas annulée
      if (printAccepted) 
      {
              //Impression
	      job.print();
      }
}
 catch(Exception PrintException)
{} | 
Partager