How to handle every mouse event in java

How to handle every mouse event in java
Event notification is a term used in conjunction with communications software for linking applications that generate smallmessages (the “events”) to applications that monitor the associated conditions and may take actions triggered by events.
Event notification is an important feature in modern database systems (used to inform applications when conditions they are watching for have occurred), modern operating systems (used to inform applications when they should take some action, such as refreshing a window), and modern distributed systems, where the producer of an event might be on a different machine than the consumer, or consumers. Event notification platforms are normally designed so that the application producing events does not need to know which applications will consume them, or even how many applications will monitor the event stream.
It is sometimes used as a synonym for publish-subscribe, a term that relates to one class of products supporting event notification in networked settings. The virtual synchrony model is sometimes used to endow event notification systems, and publish-subscribe systems, with stronger fault-tolerance and consistency guarantees.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MouseApplet extends Applet implements MouseListener
{
	String msg="Initial Message";
	public void init()
	{
		addMouseListener(this);
	}
	public void mouseClicked(MouseEvent me)
	{
		msg = "Mouse Clicked";
		repaint();
	}
	public void mousePressed(MouseEvent me)
	{
		msg = "Mouse Pressed";
		repaint();
	}
	public void mouseReleased(MouseEvent me)
	{
		msg = "Mouse Released";
		repaint();
	}
	public void mouseEntered(MouseEvent me)
	{
		msg = "Mouse Entered";
		repaint();
	}
	public void mouseExited(MouseEvent me)
	{
		msg = "Mouse Exited";
		repaint();
	}
	public void paint(Graphics g)
	{
		g.drawString(msg,20,20);
	}
}
/*
applet code="MouseApplet" width="500" height="300"
applet
*/
Pressing a key on a keyboard or a combination of keys generates a keyboard event, enabling the program currently running to respond to the introduced data such as which key/s the user pressed.
Events can also be used at instruction set level, where they complement interrupts. Compared to interrupts, events are normally handled synchronously: the program explicitly waits for an event to be serviced (typically by calling an instruction that dispatches the next event), whereas an interrupt can demand service at any time.

Please Do not Spam, use a clear English that we can understand thank you.

Previous Post Next Post

Contact Form