From b74565132a25671f62996e8fa01901c715ebf0eb Mon Sep 17 00:00:00 2001 From: Fastium <79766552+Fastium@users.noreply.github.com> Date: Wed, 18 May 2022 17:49:12 +0200 Subject: [PATCH] =?UTF-8?q?Co-authored-by:=20R=C3=A9mi=20Heredero=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BillGUI/Impression1.java | 47 ++++++++++++++++++++++++++++++++++++ src/GUI/GUI1.java | 1 + src/GUI/GUI2.java | 1 + 3 files changed, 49 insertions(+) create mode 100644 src/BillGUI/Impression1.java 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;