diff --git a/src/BillGUI/Impression1.java b/src/BillGUI/Impression1.java new file mode 100644 index 0000000..770ad96 --- /dev/null +++ b/src/BillGUI/Impression1.java @@ -0,0 +1,47 @@ +package BillGUI; +//TODO all + +import java.awt.*; +import java.awt.event.*; +import java.awt.print.*; +import javax.swing.*; + + +public class Impression1 extends JPanel implements Printable, ActionListener{ + + /** **/ + +JPanel frameToPrint; + + public int print(Graphics g, PageFormat pf, int page) throws PrinterException { + + if (page > 0) { + return NO_SUCH_PAGE; + } + + Graphics2D g2d = (Graphics2D) g; + g2d.translate(pf.getImageableX(), pf.getImageableY()); + + frameToPrint.printAll(g); + + return PAGE_EXISTS; + } + + public void actionPerformed(ActionEvent e) { + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(this); + boolean ok = job.printDialog(); + if (ok) { + try { + job.print(); + } catch (PrinterException ex) { + } + } + } + + public Impression1(JPanel f) { + frameToPrint = f; + } + + } + diff --git a/src/GUI/GUI1.java b/src/GUI/GUI1.java index ddf099f..bbefa25 100644 --- a/src/GUI/GUI1.java +++ b/src/GUI/GUI1.java @@ -1,4 +1,5 @@ package GUI; +//TODO mettre commentaire import javax.swing.*; diff --git a/src/GUI/GUI2.java b/src/GUI/GUI2.java index 6dba5c8..c192df3 100644 --- a/src/GUI/GUI2.java +++ b/src/GUI/GUI2.java @@ -1,4 +1,5 @@ package GUI; +//TODO mettre commentaire import javax.swing.*; import javax.swing.event.ChangeEvent;