import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TestEvent2 extends Applet implements ActionListener
{
       	Button b1,b2;
       	String msg=" ";
       	public void init()
	{
		b1= new Button("Hello");
		b2=new Button("Hai");
		add(b1);
		add(b2);
		b1.addActionListener(this);
		b2.addActionListener(this);
   	}
        public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==b1)
		{
			msg="Hello Pressed";
			repaint();
		}
		else if(e.getSource()==b2)
                {
			msg="Hai Pressed";
			repaint();
		}
	}
	public void paint(Graphics g)
  	{
   		g.drawString(msg,10,50);
  	}
}

Click here to go back.

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus




Footer1