Java

Java Applet - Button Component Demonstration

Java Applet - Button Component Demonstration
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class butt1 extends Applet
{
Button b1,b2;
TextField t1;

public void init()
{
t1 = new TextField(50);
b1 = new Button("one");
b2 = new Button("two");

add(b1); add(b2); add(t1);

b1.addActionListener(new a());
b2.addActionListener(new a());

}

class a implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
t1.setText("monica"); 
}
if(e.getSource()==b2)
{
t1.setText("kanimozhi"); 
}
}
}

}


/* <body>
<applet code = "butt1.class" height = 650 width = 500>
</applet>
</body> */
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.