home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / JBuilder8.iso / Solaris / resource / jre / demo / plugin / jfc / Font2DTest / src / Font2DTestApplet.java < prev    next >
Encoding:
Java Source  |  2002-09-06  |  3.4 KB  |  89 lines

  1. /*
  2.  * Copyright (c) 2002 Sun Microsystems, Inc. All  Rights Reserved.
  3.  * 
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  * 
  8.  * -Redistributions of source code must retain the above copyright
  9.  *  notice, this list of conditions and the following disclaimer.
  10.  * 
  11.  * -Redistribution in binary form must reproduct the above copyright
  12.  *  notice, this list of conditions and the following disclaimer in
  13.  *  the documentation and/or other materials provided with the distribution.
  14.  * 
  15.  * Neither the name of Sun Microsystems, Inc. or the names of contributors
  16.  * may be used to endorse or promote products derived from this software
  17.  * without specific prior written permission.
  18.  * 
  19.  * This software is provided "AS IS," without a warranty of any kind. ALL
  20.  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
  21.  * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
  22.  * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT
  23.  * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
  24.  * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
  25.  * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
  26.  * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
  27.  * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
  28.  * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
  29.  * IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  30.  * 
  31.  * You acknowledge that Software is not designed, licensed or intended for
  32.  * use in the design, construction, operation or maintenance of any nuclear
  33.  * facility.
  34.  */
  35.  
  36. /*
  37.  * @(#)Font2DTestApplet.java    1.8 02/06/13
  38.  */
  39.  
  40. import java.awt.AWTPermission;
  41. import java.awt.Frame;
  42. import java.awt.event.WindowAdapter;
  43. import java.awt.event.WindowEvent;
  44.  
  45. import javax.swing.*;
  46.  
  47. /**
  48.  * Font2DTestApplet.java
  49.  *
  50.  * @version @(#)Font2DTestApplet.java    1.1 00/08/22
  51.  * @author Shinsuke Fukuda
  52.  * @author Ankit Patel [Conversion to Swing - 01/07/30]  
  53.  */
  54.  
  55. /// Applet version of Font2DTest that wraps the actual demo
  56.  
  57. public final class Font2DTestApplet extends JApplet {
  58.     public void init() {
  59.         /// Check if necessary permission is given...
  60.         SecurityManager security = System.getSecurityManager();
  61.         if ( security != null ) {
  62.             try {
  63.                 security.checkPermission( new AWTPermission( "showWindowWithoutWarningBanner" ));
  64.             }
  65.             catch ( SecurityException e ) {
  66.                 System.out.println( "NOTE: showWindowWithoutWarningBanner AWTPermission not given.\n" +
  67.                                     "Zoom window will contain warning banner at bottom when shown\n" );
  68.             }
  69.             try {
  70.                 security.checkPrintJobAccess();
  71.             }
  72.             catch ( SecurityException e ) {
  73.                 System.out.println( "NOTE: queuePrintJob RuntimePermission not given.\n" +
  74.                                     "Printing feature will not be available\n" );
  75.             }
  76.         }
  77.         
  78.         final JFrame f = new JFrame( "Font2DTest" );
  79.         final Font2DTest f2dt = new Font2DTest( f, true );
  80.         f.addWindowListener( new WindowAdapter() {
  81.             public void windowClosing( WindowEvent e ) { f.dispose(); }
  82.         });
  83.  
  84.         f.getContentPane().add( f2dt );
  85.         f.pack();
  86.         f.show();
  87.     }
  88. }
  89.