/* * [Inauguration.java] * * Summary: countdown to next inauguration. * * Copyright: (c) 2000-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.2 2006-03-05 reformat with IntelliJ, add Javadoc. * 1.3 2009-01-20 change to Obama */ package com.mindprod.inauguration; import com.mindprod.common18.BigDate; import com.mindprod.common18.Build; import com.mindprod.common18.FontFactory; import com.mindprod.common18.Hybrid; import com.mindprod.common18.VersionCheck; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.Label; /** * countdown to next inauguration. *

* Use BigDate.age in a GUI. Demonstrates use of BigDate.age * * @author Roedy Green, Canadian Mind Products * @version 1.3 2009-01-20 change to Obama * @since 2000 */ public final class Inauguration extends Applet { /** * height of Applet box in pixels. Does not include surrounding frame. */ private static final int APPLET_HEIGHT = 36; /** * Width of Applet box in pixels. */ private static final int APPLET_WIDTH = 520; private static final int FIRST_COPYRIGHT_YEAR = 2000; /** * year of the next inauguration */ private static final int inaugYear = 2017; /** * undisplayed copyright notice */ private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2000-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; private static final String RELEASE_DATE = "2009-01-20"; /** * embedded version string */ private static final String TITLE_STRING = "Inauguration"; /** * embedded version string */ private static final String VERSION_STRING = "1.3"; /** * where we display time to next inauguration */ private Label time; /** * Allow this Applet to run as as application as well. * * @param args command line arguments are ignored. */ public static void main( String args[] ) { Hybrid.fireup( new Inauguration(), TITLE_STRING + " " + VERSION_STRING, APPLET_WIDTH, APPLET_HEIGHT ); } // end main /** * Called by the browser or Applet viewer to inform * this Applet that it is being reclaimed and that it should destroy * any resources that it has allocated. */ public void destroy() { time = null; } /** * Called by the browser or Applet viewer to inform * this Applet that it has been loaded into the system. */ public void init() { if ( !VersionCheck.isJavaVersionOK( 1, 8, 0, this ) ) { return; } // no layout setVisible( false ); setBackground( Color.green );// none should show if all is well. setLayout( new BorderLayout() ); BigDate inauguration = new BigDate( inaugYear, 1, 20 /* usually 20 */ ); // decide date based on DST and local TimeZone. BigDate today = BigDate.localToday(); int[] age = BigDate.age( today, inauguration ); StringBuilder sb = new StringBuilder( 100 ); if ( age[ 0 ] > 0 ) { sb.append( age[ 0 ] ); sb.append( ( age[ 0 ] == 1 ) ? " year, " : " years, " ); } if ( age[ 1 ] > 0 ) { sb.append( age[ 1 ] ); sb.append( ( age[ 1 ] == 1 ) ? " month, " : " months, " ); } if ( age[ 2 ] > 0 ) { sb.append( age[ 2 ] ); sb.append( ( age[ 2 ] == 1 ) ? " day, " : " days, " ); } sb.append( "left to the end of the current Obama administration." ); time = new Label( sb.toString(), Label.CENTER ); time.setBackground( Build.BACKGROUND_FOR_BLENDING ); time.setForeground( Color.blue ); time.setFont( FontFactory.build( "Dialog", Font.BOLD, 14 ) ); add( time, BorderLayout.CENTER ); setVisible( true ); } // end init }