Q:

Java Applet - Button Component Demonstration

0

This Program is used to Demonstrate Button Component using Java Applet.

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 butexam1 extends Applet
{
TextField t1,t2;
Button b1,b2,b3;


public void init()
{
t1 = new TextField(10);
t2 = new TextField(10);

b1 = new Button("Enter");
b2 = new Button("Next");
b3 = new Button("Clear");

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

add(t1); add(t2); add(b1); add(b2);add(b3);
}

class a implements ActionListener
{
public void actionPerformed(ActionEvent ee)
{
if(ee.getSource() == b1)
{
t1.setText("Welcome");
}

if(ee.getSource() == b2)
{
t2.setText("Have a Nice Day");
}

if(ee.getSource() == b3)
{
t1.setText("");
t2.setText("");
}

}
}

}

/* <applet code = "butexam1.class" height = 300 width = 300>
</applet> */

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