/*
Disable Button Example
This java example shows how to disable a Button using setEnabled method.
*/
import java.applet.Applet;
import java.awt.Button;
/*
<applet code="DisableButtonExample" width=100 height=200>
</applet>
*/
public class DisableButtonExample extends Applet{
public void init(){
//create Buttons
Button Button1 = new Button("Ok");
Button Button2 = new Button("Cancel");
//add Buttons
add(Button1);
add(Button2);
/*
* To disable a Button, use
* void setEnabled(Boolean enable)
* method.
*/
Button2.setEnabled(false);
}
}
Example Output

Bookmark/Search this post with: