/*
 * Filename: QuickButtonApplet1.java
 * Written By: Sunit Katkar
 * E-Mail:sunitkatkar@hotmail.com
 * Home-Page : www.vidyut.com/sunit
 * Java Page : www.vidyut.com/sunit/JavaPage.html
 ***************************************************************
 * Description:
 * Are you bored waiting for an image to download in a applet ?
 * Do you site behind a firewall? Does a ImageButton which you see
 * everywhere take long to load ? Then here is a simple NON-IMAGE
 * yet somewhat attractive and configurable button which loads
 * quickly.
 * This applet uses three such Quick buttons. *
 *
 * What's NEW in this version :
 * You can have same sized buttons. All you have to do is -
 * a) plan what will the (text) labels for each button.
 * b) pass the text string you want for a button followed
 *    by the LONGEST string you have planned for a button
 ****************************************************************
 * Copyright (c) 1997 Sunit Katkar All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * for NON-COMMERCIAL or COMMERCIAL purposes and without fee
 * is hereby granted.
 *
 * Whew ! That was too much legalese..even to have copied and pasted
 * from some other place... PLEASE DO NOT BLAME ME in any way
 * if your system crashes because of this code, or if anything else
 * bad happens. In short "DO WHAT YOU WANT BUT DONT BLAME ME !"
 *****************************************************************/

import java.awt.*;
import java.applet.*;

public class QuickButtonApplet1 extends Applet
{

        public QuickButton1 testButton1,testButton2,testButton3,testButton4;
        public Panel pnl1,pnl2,pnl3,pnl4,pnl5;
        public Panel mainpnl;
        public Label lbl;
        public Color c;

public void init()
{
        setLayout(new GridLayout(5,1,2,2));
        setBackground (Color.blue);
        addNotify();
    /************** WHATS NEW !*****************************************
   * Constructor : String firstlabel - text of the 1st button's label
   *             : String secondlabel - text of the 2nd button's label
   *             : String font  -  Font to construct the label
   *             : int fontsize - Size of font
   *             : Color c      - Color to use as foreground of label
   ********************************************************************/    
   //public QuickButton(String label, String font, int fontsize, Color c)
    //Try making your own colors like Color c = new Color(255,128,0);
    c = new Color(0,128,0);

    testButton1 = new QuickButton1("Quick","Button1", "Dialog",14,Color.red);
    testButton2 = new QuickButton1("Button1","Button1","Dialog",14,Color.red );
    testButton3 = new QuickButton1("Disabled Button","Disabled Button","Dialog",
                                    14,c);
    testButton4 = new QuickButton1("New Button","Disabled Button","Dialog",
                                    14,Color.blue);

        lbl = new Label(" ", Label.CENTER);
        lbl.setText("Click first and second button");
        lbl.setForeground(Color.red);
        lbl.setFont(new Font("Dialog",Font.BOLD,12));

        pnl1 = new Panel();
        pnl2 = new Panel();
        pnl3 = new Panel();
        pnl4 = new Panel();
        pnl5 = new Panel();
        pnl4.setLayout(new FlowLayout(FlowLayout.CENTER,2,5));

        pnl1.setBackground (Color.white);
        pnl2.setBackground (Color.white);
        pnl3.setBackground (Color.white);
        pnl4.setBackground (Color.white);
        pnl5.setBackground (Color.white);

        pnl1.add(testButton1);
        pnl2.add(testButton2);
        pnl3.add(testButton3);
        pnl4.add(testButton4);
        pnl5.add(lbl);

        add(pnl1);
        add(pnl2);
        add(pnl3);
        add(pnl4);
        add(pnl5);
        testButton3.disablebutton();

        validate();
        show();
}

    public boolean action(Event e, Object o)
    {
        if (e.target == testButton1)
        {
           testButton3.enablebutton();
           lbl.setText("");
           lbl.setText("You enabled third button");
           return false;
        }
        else if(e.target == testButton2 )
        {
                 if(testButton3.enablebutton())
         testButton3.disablebutton();
         lbl.setText("");
         lbl.setText("You disabled third button");
         return false;
        }
        else if(e.target == testButton3 )
        {
             if(testButton3.enablebutton())
             {
                 lbl.setText("");
                 lbl.setText("You clicked third button");
             }
             else if(testButton3.disablebutton())
             {
                lbl.setText("");
                lbl.setText("Click first and second button");
             }
             return false;
        }
        else if(e.target == testButton4 )
        {
            lbl.setText("");
            lbl.setText("Button 4 size same as third");
        }
        return true;
}

}//Applet ends :) 
The source code for the QuickButton1 class is here. See the applet in action.