Java 2D Graphics public class FileOpenAction extends AbstractAction
Java 2D Graphics public class FileOpenAction extends AbstractAction { public FileOpenAction() { super(”Open…”); } public void actionPerformed(ActionEvent ae) { // Pop up a file dialog. JFileChooser fc = new JFileChooser(”.”); int result = fc.showOpenDialog(FilePrinter.this); if (result != 0) { return; } java.io.File f = fc.getSelectedFile(); if (f == null) { return; } // Load the specified file. try { mPageRenderer = new FilePageRenderer(f, mPageFormat); mTitle = “[” + f.getName() + “]”; showTitle(); JScrollPane jsp = new JScrollPane(mPageRenderer); getContentPane().removeAll(); getContentPane().add(jsp, BorderLayout.CENTER); validate(); } catch (java.io.IOException ioe) { System.out.println(ioe); } } } public class FilePrintAction extends AbstractAction { public FilePrintAction() { super(”Print”); } public void actionPerformed(ActionEvent ae) { PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(mPageRenderer, mPageFormat); if (pj.printDialog()) { try { pj.print(); } catch (PrinterException e) { System.out.println(e); } } } } public class FilePageSetupAction extends AbstractAction { public FilePageSetupAction() { super(”Page setup…”); } public void actionPerformed(ActionEvent ae) { PrinterJob pj = PrinterJob.getPrinterJob(); mPageFormat = pj.pageDialog(mPageFormat); if (mPageRenderer != null) { mPageRenderer.paginate(mPageFormat); showTitle(); } } } public class FileQuitAction extends AbstractAction { public FileQuitAction() { super(”Quit”); } public void actionPerformed(ActionEvent ae) { System.exit(0); } } public class PageNextPageAction page 248
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services