/* * [PR.java] * * Summary: Test proofreader font. * * Copyright: (c) 1998-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 1998-07-08 original. */ package com.mindprod.proofreader; import com.mindprod.common18.VersionCheck; import java.applet.Applet; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; /** * Test proofreader font. * * @author Roedy Green, Canadian Mind Products * @version 1.0 1998-07-08 original. * @since 1998-07-08 */ public class PR extends Applet { /** * canvas on which to draw the proofreader font characters */ PRCanvas canvas; /** * Allow this applet to run as as application as well. * * @param args command line arguments are ignored. */ public static void main( String args[] ) { final PR applet = new PR(); Frame frame = new Frame( "Proofreader" ); frame.setVisible( true ); frame.setSize( 600, 390 ); frame.add( applet ); applet.init(); applet.invalidate(); applet.validate(); applet.repaint(); frame.setVisible( true ); frame.invalidate(); frame.validate(); frame.repaint(); applet.start(); frame.addWindowListener ( new java.awt.event.WindowAdapter() { /** * Handle request to shutdown. * * @param e event with details of shutdown. */ public void windowClosing( java.awt.event.WindowEvent e ) { applet.stop(); applet.destroy(); System.exit( 0 ); } // end WindowClosing } // end anonymous class ); // end addWindowListener line } // end main /** * Get the applet started. */ public void init() { if ( !VersionCheck.isJavaVersionOK( 1, 1, 0, this ) ) { return; } setBackground( Color.white ); setForeground( Color.black ); GridBagLayout gridBagLayout; gridBagLayout = new GridBagLayout(); GridBagConstraints gbc; setLayout( gridBagLayout ); canvas = new PRCanvas(); canvas.setFont( new Font( "Dialog", Font.PLAIN, 10 ) ); canvas.setSize( 100, 100 ); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 100.0; gbc.weighty = 100.0; gbc.ipadx = 100; gbc.ipady = 100; gbc.anchor = GridBagConstraints.CENTER; // must be BOTH or else will have zero size. gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets( 5, 20, 5, 20 ); ( ( GridBagLayout ) getLayout() ).setConstraints( canvas, gbc ); add( canvas ); this.invalidate(); // calculate the layouts this.setVisible( true ); // Lights, Camera, Action. this.validate(); canvas.repaint(); // grasping at straws here. this.repaint(); } // end init } // end class PR