Q:

Java Applet - Button Component Demonstration

0

This Program is used to Button Demonstration using Java Applet concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now