import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/**
<applet code=”LabelButtonDemo.class” width=500 height=500>
</applet>
*/
public class LabelButtonDemo extends Applet implements ActionListener
{
Label l;
Button b1;
String str;
FlowLayout f;
TextField t;
TextArea ta;
public void init()
{
f=new FlowLayout(FlowLayout.CENTER,240,18);
setLayout(f);
l=new Label(“Label”);
l.setBackground(color.gray);
l.setForeground(color.white);
t=new TextField(“Text”,20);
ta=new TextArea(“Welcome\nTo\nTextArea”,10,50,TextArea.SCROLLBARS_BOTH);
b1=new Button(“click”);
b1.addActionListener(this);
add(l);
add(b1);
add(t);
add(ta);
}
public void actionPerformed(ActionEvent e)
{
str=e.getActionCommand();
if(str==”click”)
{
l.setText(“I am Label”);
ta.append(“\nButton Clcked”);
t.setText(“Button Clicked”);
}}}
No comments:
Post a Comment