/*
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.