Code:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Queue
*/
public class mm extends Applet implements MouseListener{
String msg="";
public void init()
{
setSize(400,400);
addMouseListener(this);
}
public void paint(Graphics s)
{
showStatus(msg);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
msg="Mouse Pressed";
repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
msg="Mouse Released";
repaint();
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
Output:
Thanks
Happy Coding ;)
import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Queue
*/
public class mm extends Applet implements MouseListener{
String msg="";
public void init()
{
setSize(400,400);
addMouseListener(this);
}
public void paint(Graphics s)
{
showStatus(msg);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
msg="Mouse Pressed";
repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
msg="Mouse Released";
repaint();
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
Output:
Happy Coding ;)
No comments:
Post a Comment