src/share/classes/sun/applet/AppletViewer.java

Print this page




 651                 // FileDialog is created, enough time is given such that this
 652                 // situation is unlikely to ever occur.
 653 
 654                 panel.sendEvent(AppletPanel.APPLET_STOP);
 655                 FileDialog fd = new FileDialog(AppletViewer.this,
 656                                                amh.getMessage("appletsave.filedialogtitle"),
 657                                                FileDialog.SAVE);
 658                 // needed for a bug under Solaris...
 659                 fd.setDirectory(System.getProperty("user.dir"));
 660                 fd.setFile(defaultSaveFile);
 661                 fd.show();
 662                 String fname = fd.getFile();
 663                 if (fname == null) {
 664                     // Restart applet if Save is cancelled.
 665                     panel.sendEvent(AppletPanel.APPLET_START);
 666                     return null;                // cancelled
 667                 }
 668                 String dname = fd.getDirectory();
 669                 File file = new File(dname, fname);
 670 
 671                 try {
 672                     BufferedOutputStream s = new BufferedOutputStream(new FileOutputStream(file));
 673                     ObjectOutputStream os = new ObjectOutputStream(s);
 674                     showStatus(amh.getMessage("appletsave.err1",
 675                                               panel.applet.toString(), file.toString()));
 676                     os.writeObject(panel.applet);
 677                 } catch (IOException ex) {
 678                     System.err.println(amh.getMessage("appletsave.err2", ex));
 679                 } finally {
 680                     panel.sendEvent(AppletPanel.APPLET_START);
 681                 }
 682                 return null;
 683             }
 684         });
 685     }
 686 
 687     /**
 688      * Clone the viewer and the applet.
 689      */
 690     void appletClone() {
 691         Point p = location();
 692         updateAtts();
 693         factory.createAppletViewer(p.x + XDELTA, p.y + YDELTA,
 694                                    panel.documentURL, (Hashtable)panel.atts.clone());
 695     }




 651                 // FileDialog is created, enough time is given such that this
 652                 // situation is unlikely to ever occur.
 653 
 654                 panel.sendEvent(AppletPanel.APPLET_STOP);
 655                 FileDialog fd = new FileDialog(AppletViewer.this,
 656                                                amh.getMessage("appletsave.filedialogtitle"),
 657                                                FileDialog.SAVE);
 658                 // needed for a bug under Solaris...
 659                 fd.setDirectory(System.getProperty("user.dir"));
 660                 fd.setFile(defaultSaveFile);
 661                 fd.show();
 662                 String fname = fd.getFile();
 663                 if (fname == null) {
 664                     // Restart applet if Save is cancelled.
 665                     panel.sendEvent(AppletPanel.APPLET_START);
 666                     return null;                // cancelled
 667                 }
 668                 String dname = fd.getDirectory();
 669                 File file = new File(dname, fname);
 670 
 671                 try (ObjectOutputStream os = new ObjectOutputStream(
 672                         new BufferedOutputStream(new FileOutputStream(file)))) {
 673 
 674                     showStatus(amh.getMessage("appletsave.err1", panel.applet.toString(), file.toString()));

 675                     os.writeObject(panel.applet);
 676                 } catch (IOException ex) {
 677                     System.err.println(amh.getMessage("appletsave.err2", ex));
 678                 } finally {
 679                     panel.sendEvent(AppletPanel.APPLET_START);
 680                 }
 681                 return null;
 682             }
 683         });
 684     }
 685 
 686     /**
 687      * Clone the viewer and the applet.
 688      */
 689     void appletClone() {
 690         Point p = location();
 691         updateAtts();
 692         factory.createAppletViewer(p.x + XDELTA, p.y + YDELTA,
 693                                    panel.documentURL, (Hashtable)panel.atts.clone());
 694     }