/*
 * Filename: Filename: QuickCoolButtonApplet.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
 * and BORDERLESS button which loads quickly.
 * Features :
 * 1) 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
 * 2) You can change the Button label (text) programatically
 ***************************************************************
 * 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 QuickCoolButtonApplet extends Applet
{

    public QuickCoolButton testButton0,testButton1,testButton2,
                           testButton3,testButton4;
    public QuickPanel pnl2,pnl3;
    public QuickLabelPanel pnl1,pnl4;
    public Panel pnl5;
    public Label lbl;
    public Color c;

public void init()
{
  setLayout(new GridLayout(5,1,2,2));
  setBackground (Color.lightGray);
  addNotify();
 
//Try making your own colors like Color c = new Color(255,128,0);
  c = new Color(0,102,0);

  testButton0 = new QuickCoolButton("Cool","Buttons","Dialog",14,Color.red);
  testButton1 = new QuickCoolButton("Buttons","Buttons","Dialog",14,Color.red);
  testButton2 = new QuickCoolButton("Click Me","Click Me","Dialog",14,Color.red );
  testButton3 = new QuickCoolButton("Disabled Button","Disabled Button","Dialog",
                                                                         14,c);
  testButton4 = new QuickCoolButton("Watch Me!","Disabled Button","Dialog",
                                                            14,Color.blue);

  lbl = new Label("Click these COOL BORDERLESS buttons", Label.LEFT);
  lbl.setForeground(Color.green);
  lbl.setFont(new Font("Dialog",Font.BOLD,12));

  pnl1 = new QuickLabelPanel("Move Mouse Over Labels");
  pnl2 = new QuickPanel(QuickPanel.ETCH);
  pnl3 = new QuickPanel(QuickPanel.ETCH);
  pnl4 = new QuickLabelPanel("Observe this button's states");
  pnl5 = new Panel();

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

  pnl1.setBackground (Color.lightGray);
  pnl2.setBackground (Color.lightGray);
  pnl3.setBackground (Color.lightGray);
  pnl4.setBackground (Color.lightGray);
  pnl5.setBackground (Color.black);
  pnl5.setForeground(Color.green);

  pnl1.add(testButton0);
  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 void paint (Graphics g)
{
        g.setColor(Color.gray);
}

public boolean action(Event e, Object o)
{
    if (e.target == testButton0)
        {
           testButton3.enablebutton();
           testButton3.setButtonLabel("Enabled button");
           lbl.setText("You clicked COOL and enabled third button");
           testButton4.setButtonLabel("Change");
           return false;
        }
        else if(e.target == testButton1)
        {
                testButton4.setButtonLabel("Watch Me");
        return false;
        }
        else if(e.target == testButton2 )
        {
         if(testButton3.enablebutton())

                  
            testButton3.setButtonLabel("Disabled Button");
             testButton3.disablebutton();
             lbl.setText("You clicked CLICK ME and disabled third button");
          }
         return false;
        }
        else if(e.target == testButton3 )
        {
                 if(testButton3.enablebutton())
                 {
                    lbl.setText("You clicked ENABLED BUTTON");
                    testButton4.setButtonLabel("Changed");
                 }
                 else if(testButton3.disablebutton())
                 {
                    lbl.setText("Click COOL and CLICK ME");
                 }
                return false;
        }
        else if(e.target == testButton4 )
        {
                lbl.setText("My size is same as the one above");
                testButton4.setButtonLabel("Like it?");
        }
        return true;
}

}
//All ends :)


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