Co-authored-by: Rémi Heredero <Klagarge@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										47
									
								
								src/BillGUI/Impression1.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								src/BillGUI/Impression1.java
									
									
									
									
									
										Normal 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; | ||||
|   } | ||||
|  | ||||
|  } | ||||
|  | ||||
| @@ -1,4 +1,5 @@ | ||||
| package GUI; | ||||
| //TODO mettre commentaire | ||||
|  | ||||
| import javax.swing.*; | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| package GUI; | ||||
| //TODO mettre commentaire | ||||
|  | ||||
| import javax.swing.*; | ||||
| import javax.swing.event.ChangeEvent; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user