File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ranch Office and the fly likes Inner Class Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "Inner Class Question" Watch "Inner Class Question" New topic

Inner Class Question


Joined: Jul 18, 2001
Posts: 1
We know that when we implemnt an interface we should implement
all the methods in the interface. It also does in the "inner
class" when we use "inner class" to implemnet the interface or
you will get error message that force you to declare "inner
class" as abstract class.
But, now i was confused by following example
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class AdapterSpot extends Applet //no implements clause
private Point clickPoint = null;
private static final int RADIUS = 7;
public void init() {
addMouseListener(new MyMouseAdapter());
public void paint(Graphics g) {
g.drawRect(0, 0, getSize().width - 1,
getSize().height - 1);
if (clickPoint != null)
class MyMouseAdapter extends MouseAdapter {
public void mousePressed(MouseEvent event) {
clickPoint = event.getPoint();
/* no empty methods! */

Hence, MouseAdapter is an "interface" including five
methods,but, why MyMouseAdapter can ONLY implement mousePressed
mdthod without other methods and work
thax.... ccchang
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
MoseAdapter is not an interface. It is an abstract class with no abstract methods.
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Two things:
First, this forum is NOT for real Java Questions. This forum is to discuss JavaRanch itself. Please use the other forums in the future.
Also, please change your name to be compliant with JavaRanch's naming policy.
Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Inner Class Question
It's not a secret anymore!