/*
 * Filename: QuickButtonApplet.java
 * Written By: Sunit Katkar
 * E-Mail:sunitkatkar@hotmail.com
 * Home-Page : http://www.vidyut.com/sunit
 * Java Page : www.vidyut.com/sunit/JavaPage.asp
 ***************************************************************
 * 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 QuickButtons.
 ****************************************************************
 * 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 QuickButtonApplet extends Applet

{

 public QuickButton testButton1,testButton2,testButton3;

 public Color c;

 public Panel pnl1,pnl2,pnl3,pnl4;

 public Panel mainpnl;

 public Label lbl;
public void init()

{   

    setLayout(new GridLayout(4,1,2,2));

    setBackground (Color.blue);

    addNotify();
   /**

    * public QuickButton(String label, String font, int fontsize, Color c)  

    * QuickButton Constructor  takes

    * - String label - text which is the button's label

    * - String font  -  Font to construct the label

    * - int fontsize - Size of font

    * - Color c      - Color to use as foreground of label

    **/
    c = new Color(0,128,0); //try your combinations
    testButton1 = new QuickButton("Quick", "Dialog",12,Color.red);

    testButton2 = new QuickButton("Button", "Dialog",14,Color.blue);

    testButton3 = new QuickButton("Disabled Button","Dialog",14,c);
    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();

    pnl4.setLayout(new FlowLayout(FlowLayout.CENTER,2,5));

    pnl1.setBackground (Color.white);

    pnl2.setBackground (Color.white);

    pnl3.setBackground (Color.white);

    pnl4.setBackground (Color.white);
    pnl1.add(testButton1);

    pnl2.add(testButton2);

    pnl3.add(testButton3);

    pnl4.add(lbl);
    add(pnl1);

    add(pnl2);

    add(pnl3);

    add(pnl4);
    testButton3.disablebutton();
    validate();

    show();

}
//I personally prefer the JDK1.1 AWT-Event Delegation model. It is very 

//convenient and coding is cleaner, but not everybody is using a JDK 1.1 

//compliant browser like Netscape Communiator or MSIE 4.
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;

    }
 return true;
}
} //Applet ends :) 

The source code for the QuickButton class is here. See the applet in action.