import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TestEvent extends Applet implements MouseListener
{
	Button b1,b2;
	String msg=" ";
	public void init()
	{
		b1=new Button("Hello");
                add(b1);
   		b1.addMouseListener(this);
	}
               
	public void mousePressed(MouseEvent me)
        {
		msg="mouse Pressed";
             	repaint();
        } 	
	public void mouseClicked(MouseEvent me)
        {
		msg="mouse clicked";
             	repaint();
        } 	
	public void mouseReleased(MouseEvent me)
        {
		msg="mouse Released";
             	repaint();
        } 	
	public void mouseExited(MouseEvent me)
        {
		msg="mouse exited";
             	repaint();
        } 	
	public void mouseEntered(MouseEvent me)
        {
		msg="mouse Entered";
		//System.out.println("Mouse Entered"); u can use this but it will display the message on the console
             	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