home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / sun / applet / AppletCopyright.java < prev    next >
Encoding:
Java Source  |  1997-01-27  |  2.8 KB  |  100 lines

  1. /*
  2.  * @(#)AppletCopyright.java    1.7 96/03/29
  3.  *
  4.  * Copyright (c) 1994-1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package sun.applet;
  21.  
  22. import java.awt.*;
  23. import java.io.*;
  24. import java.util.*;
  25.  
  26. /**
  27.  * Applet copyright splash screen.
  28.  */
  29. class AppletCopyright extends Frame {
  30.     AppletCopyright() {
  31.     setTitle("Copyright Notice");
  32.     Panel p = new Panel();
  33.     Dimension dims = Toolkit.getDefaultToolkit().getScreenSize();
  34.     TextArea txt = new TextArea((dims.height / 2) / 12, (int) (dims.width / 2) / 7);
  35.     txt.setEditable(false);
  36.     txt.setText(load());
  37.     txt.setFont(new Font("Courier", Font.BOLD, 12));
  38.     p.add(new Button("Accept"));
  39.     p.add(new Button("Reject"));
  40.     add("Center", txt);
  41.     add("South", p);
  42.     pack();
  43.     Dimension d = size();
  44.     Dimension scrn = getToolkit().getScreenSize();
  45.     move((scrn.width - d.width) / 2, (scrn.height - d.height)/ 2);
  46.     show();
  47.     }
  48.     String load() {
  49.     File f = new File(System.getProperty("java.home") + 
  50.               System.getProperty("file.separator") + "COPYRIGHT");
  51.     try {
  52.         if (f.canRead()) {
  53.         ByteArrayOutputStream out = new ByteArrayOutputStream();
  54.         FileInputStream in = new FileInputStream(f);
  55.         byte buf[] =new byte[256];
  56.         int n;
  57.         while ((n = in.read(buf, 0, buf.length)) >= 0) {
  58.             out.write(buf, 0, n);
  59.         }
  60.         in.close();
  61.         return out.toString();
  62.         }
  63.     } catch (IOException e) {
  64.     }
  65.     return "Copyright 1995 Sun Microsystems Inc.";
  66.     }
  67.  
  68.     public synchronized boolean action(Event evt, Object arg) {
  69.     if ("Reject".equals(arg)) {
  70.         System.exit(1);
  71.         return true;
  72.     }
  73.     if ("Accept".equals(arg)) {
  74.         dispose();
  75.         notify();
  76.  
  77.         // Get properties, set version
  78.         Properties props = System.getProperties();
  79.         props.put("appletviewer.version", AppletViewer.theVersion);
  80.  
  81.         // Save properties
  82.         try {
  83.         FileOutputStream out = new FileOutputStream(AppletViewer.theUserPropertiesFile);
  84.         props.save(out, "AppletViewer");
  85.         out.close();
  86.         } catch (IOException e) {
  87.         }
  88.         return true;
  89.     }
  90.     return false;
  91.     }
  92.  
  93.     public synchronized void waitForUser() {
  94.     try {
  95.         wait();
  96.     } catch (InterruptedException e) {
  97.     }
  98.     }
  99. }
  100.