Instance of abstract class

Post here if you don't find any other place for your post. But please, stay on-topic: algorithms, programming or something related to this web site and its services.

Moderator: Board moderators

Post Reply
napestershine
New poster
Posts: 1
Joined: Fri Oct 11, 2013 9:02 am

Instance of abstract class

Post by napestershine » Fri Oct 11, 2013 9:13 am

/*
I wrote the following code :
*/
// Demosterate an adapter

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

/* <applet code="AdapterDemo" width=500 height=300>
</applet>
*/

public class AdapterDemo extends Applet
{

public void init()
{
addMouseListener(new MouseAdapter(this));
addMouseMotionListener(new MouseMotionAdapter(this));
}
}

class MyMouseAdapter extends MouseAdapter
{

AdapterDemo adapterDemo;
public MyMouseAdapter(AdapterDemo adapterDemo)
{
this.adapterDemo=adapterDemo;
}

// Handle Mouse clicked events
public void mouseClicked(MouseEvent me)
{
adapterDemo.showStatus("mouseClicked");
}
}

class MyMouseMotionAdapter extends MouseMotionAdapter
{

AdapterDemo adapterDemo;

public MyMouseMotionAdapter(AdapterDemo adapterDemo)
{
this.adapterDemo = adapterDemo;
}

// Handle Mouse Drag.
public void mouseDragged(MouseEvent me)
{
adapterDemo.showStatus("MouseDragged");
}
}


/* It shows error of Instance of abstract class.
Any solution?
*/

Post Reply

Return to “Other words”