/* * Copyright (c) 2003,2004 Aly Merchant * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the * use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. */ package tenk; import java.util.ArrayList; import java.awt.Font; import javax.swing.*; public class FunRun implements Comparable,Runnable { private static final int LNAME=2, FNAME=1; String fname, lname; int prints; FunRun() {} public int compareTo( Object other ) { if (!(other instanceof FunRun)) return 0; return fname.compareTo(((FunRun)other).fname); } public FunRun (String big) { String[] s = big.split(","); initFromStrings(s); } public FunRun (String[] s) { initFromStrings(s); } public void initFromStrings(String[] s) { fname = s[FNAME].trim(); lname = s[LNAME].trim(); prints = 0; } public FunRun (String f, String l, int p) { fname =f; lname=l; prints=p; } public void makeCert(Cert c) { c.addLine("This is to certify that",750d/6800,new Font("Verdana",Font.PLAIN,16)); c.addLine(getFullName(),1300d/6800,new Font("Times New Roman",Font.ITALIC,36)); c.addLine("Completed the Ismaili Run for Charity",4400d/6800,new Font("Verdana",Font.PLAIN,16)); c.addLine("In support of Sick Children's Hospital",4600d/6800,new Font("Verdana",Font.PLAIN,16)); c.addLine("June 20, 2004",5600d/6800,new Font("Times New Roman",Font.PLAIN,16)); } public String getFullName() { return fname+" "+lname; } public String toString() { return getFullName()+" ["+prints+"] "; } public void run() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Certificate Preview"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new Cert(this)); frame.setBounds(40,40,550,700); frame.show(); } public static void main(String[] args) { SwingUtilities.invokeLater( new FunRun(args) ); } }