Co-authored-by: Rémi Heredero <Klagarge@users.noreply.github.com>

This commit is contained in:
Fastium 2022-05-18 17:49:12 +02:00
parent 10968b25d6
commit b74565132a
3 changed files with 49 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -1,4 +1,5 @@
package GUI;
//TODO mettre commentaire
import javax.swing.*;

View File

@ -1,4 +1,5 @@
package GUI;
//TODO mettre commentaire
import javax.swing.*;
import javax.swing.event.ChangeEvent;