only ugly full screen
This commit is contained in:
		
							
								
								
									
										7
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,12 @@ | ||||
| { | ||||
|     "configurations": [ | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch HesSoGarage", | ||||
|             "request": "launch", | ||||
|             "mainClass": "BillGUI.HesSoGarage", | ||||
|             "projectName": "Lab15_OOP_90898795" | ||||
|         }, | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch HesSoGarage", | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1$1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1$1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -3,6 +3,8 @@ package BillGUI; | ||||
| import java.awt.*; | ||||
| import java.awt.event.*; | ||||
| import javax.swing.*; | ||||
| import java.awt.print.*; | ||||
| import java.awt.image.BufferedImage; | ||||
|  | ||||
| public class BillGui extends JFrame{ | ||||
|     String bill; | ||||
| @@ -26,18 +28,52 @@ public class BillGui extends JFrame{ | ||||
|         this.add(jP); | ||||
|  | ||||
|         JButton buttonPrint = new JButton("Print"); | ||||
|         buttonPrint.addActionListener(new Impression1(jP));  | ||||
|         /* | ||||
|         buttonPrint.addActionListener( | ||||
|          | ||||
|             new ButtonListenerBill(this) { | ||||
|             @Override | ||||
|             public void actionPerformed(ActionEvent e){ | ||||
|                 // TO-DO : print the pdf | ||||
|             }; | ||||
|         });*/ | ||||
|  | ||||
|                 PrinterJob pj = PrinterJob.getPrinterJob(); | ||||
|                 pj.setJobName("Bill"); | ||||
|  | ||||
|                 Printable printable = new Printable() {     | ||||
|                     public int print(Graphics pg, PageFormat pf, int pageNum){ | ||||
|                         if (pageNum > 0) return Printable.NO_SUCH_PAGE; | ||||
|  | ||||
|                         Dimension size = jP.getSize(); | ||||
|                         BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); | ||||
|      | ||||
|                         jP.print(bufferedImage.getGraphics()); | ||||
|      | ||||
|                         Graphics2D g2 = (Graphics2D) pg; | ||||
|                         g2.translate(pf.getImageableX(), pf.getImageableY()); | ||||
|                         g2.drawImage(bufferedImage, 0, 0, (int) pf.getWidth(), (int) pf.getHeight(), null); | ||||
|  | ||||
|                         return Printable.PAGE_EXISTS; | ||||
|                     } | ||||
|                 }; | ||||
|  | ||||
|                 Paper paper = new Paper(); | ||||
|                 paper.setImageableArea(0, 0,2480,3508); | ||||
|                 paper.setSize(2480,3508); | ||||
|              | ||||
|                 PageFormat format = new PageFormat(); | ||||
|                 format.setPaper(paper); | ||||
|                 format.setOrientation(PageFormat.PORTRAIT); | ||||
|  | ||||
|                 pj.setPrintable (printable, format); | ||||
|  | ||||
|                 if (pj.printDialog() == false) return; | ||||
|  | ||||
|                 try { | ||||
|                     pj.print(); | ||||
|                 } catch (PrinterException ex) {} | ||||
|             } | ||||
|         }); | ||||
|         this.add(buttonPrint); | ||||
|  | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -51,8 +87,12 @@ class ButtonListenerBill implements ActionListener { | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public void actionPerformed(ActionEvent e){ | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     public void actionPerformed(ActionEvent e){  }; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -3,10 +3,9 @@ package BillGUI; | ||||
| public class HesSoGarage { | ||||
|     public static void main(String[] args) { | ||||
|         GarageManager garageManager = new GarageManager(); | ||||
|         ManagerGui managerGui; | ||||
|         String name = "\033[3mGarage manager\033[0m\nPrestations"; //TODO résoudre en italique | ||||
|         String logoFilePath = "src/logo_garage.png"; //TODO redimensionnement automatique | ||||
|         managerGui = new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimmensionnement | ||||
|         new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimensionnement | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,47 +0,0 @@ | ||||
| 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; | ||||
|   } | ||||
|  | ||||
|  } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user