source code name: btenabledisable.java

 import java.awt.*;
    import java.awt.event.*;
 class btenabledisable extends Frame implements ActionListener
{

TextField t1;
 public btenabledisable()
{  
FlowLayout fl=new FlowLayout(1,20,10);
setLayout(fl);      
t1=new TextField(25);
Button b1=new Button("enable");
Button b2=new Button("disable");
add(b1);add(b2);
add(t1);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
System.out.println("working ");
String str=ae.getActionCommand();
t1.setText(str);

if(str.equals("enable"))
t1.setEnabled(true);

if(str.equals("disable"))
t1.setEnabled(false);

}
 
    public static void main(String[] args) {  
btenabledisable f=new btenabledisable();
f.setTitle("windows programs");
f.setSize(400,500);  
 f.setVisible(true);  
    }
}  

output: