Practical-6 Develop an applet that uses the mouse listener, which overrides only two methods which are mousePressed and mouseReleased.

 

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

public class Practical6 extends Applet implements MouseListener {

    String msg="";

    public void init() {

        setSize(400,400);

        addMouseListener(this);

    }

    public void paint(Graphics g)

    {

        showStatus(msg);

    }

    public void mousePressed(MouseEvent e)

    {

        msg="Mouse Pressed";

        repaint();

    }

    public void mouseReleased(MouseEvent e)

    {

        msg="Mouse Released";

        repaint();

    }

    public void mouseExited(MouseEvent e) {

        

    }

    public void mouseEntered(MouseEvent e) {

       

    }

    public void mouseClicked(MouseEvent e) {

       

    }

}

Output:


Comments

Popular posts from this blog

Write a program to check whether empty query string is entered in Asp.Net.

Mandavrayji Temple, Muli, Surendranagar, Gujarat

Write a program to change color of Label text control programmatically in Asp.Net.