Advertisements
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


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):


Advertisements
  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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: