Home > Java > Java Program to write an applet with Mouse Event Handling using inner class which extends MouseAdapter – Q51

Java Program to write an applet with Mouse Event Handling using inner class which extends MouseAdapter – Q51

January 26, 2009 Leave a comment Go to comments

Q51: Java Program to write an applet which does mouse event handling using concept of inner class which extends MouseAdapter.

import java.applet.*;
import java.awt.event.*;

public class Ap_MousePressedDemo extends Applet{
	public void init(){
		addMouseListener(new MyMouseAdapter(this));
	}
}

class MyMouseAdapter extends MouseAdapter{
	Ap_MousePressedDemo mousePressedDemo;
	public MyMouseAdapter(Ap_MousePressedDemo mousePressedDemo){
		this.mousePressedDemo = mousePressedDemo;
	}
	public void mousePressed(MouseEvent me){
		mousePressedDemo.showStatus("Mouse Pressed.");
	}
} 

… from College notes (BCA/MCA assignments):


Advertisement
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: