Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

inner classes within applets

Posted on 2000-05-11
9
Medium Priority
?
201 Views
Last Modified: 2013-11-23
I'm using Sun Java 2 v1.2.2 (think! latest, anyway)

I understand the difference between implementing a KeyListener inteface and creating an inner class which extends KeyAdaptor in that empty methods need not be created in the latter case.
As an exercise I'm trying to create an outer class which contains BOTH KeyAdaptor and MouseAdaptor extended inner classes called K and M for the sake of argument.

I get a compile error whenever I have both K and M defined as innder classes within the outer class source file but as soon as I comment out either one, it compiles fine.

Is there a limit to how many inner classes one can create?

The answer to this is not in any one of my three Java reference books.





0
Comment
Question by:simonm99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 2801739
Simon:

The following works fine for myself.  I compiled it with the Java SDK 2 (1.3), but it should work fine as well under 1.2.2.  Post the simplified code of your class and the error message that you get when you compile and we'll find out what the problem is.

And no, there is no limit to the number of inner classes that one can create (at least not a limit within our reasonable needs).

import java.awt.event.*;

class Adapters {
      class M extends MouseAdapter{
      }
      class K extends KeyAdapter{
      }
}

Laminamia :)
0
 
LVL 3

Accepted Solution

by:
Laminamia063099 earned 150 total points
ID: 2801743
Simon:

                The following works fine for myself.  I compiled it with the Java SDK 2 (1.3), but it should work fine as well under 1.2.2.  Post the simplified code of your class and the error message that you get when you compile and we'll find out what the problem is.

And no, there is no limit to the number of inner classes that one can create (at least not a limit within our reasonable needs).

                import java.awt.event.*;

                class Adapters {
                class M extends MouseAdapter{
                }
                class K extends KeyAdapter{
                }
                }

Laminamia :)
0
 

Author Comment

by:simonm99
ID: 2803542
that has removed the possibilty of a compiler limitation. I'll post the simplified code on monday when I get back.

thanks for answering , I do appreciate it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Laminamia063099
ID: 2804167
No problem, I'll check it out on Monday.
0
 

Author Comment

by:simonm99
ID: 2816388
I solved it, the file was called KeyAndMouse.java, the class had KeyAndMouse within its definition.

I finally worked out that "javac keyandmouse.java" didn't compile successfully although "javac KeyAndMouse.java" did compile and work perfectly well.

Obvious, you might say but the javac compiler didn't protest that it couldn't find the file, it just failed to compile it completely unless the parameter filename case was perfect.

Error was about class name not being same as .java filename, which I had thought might be the compiler being confused about multiple inner classes as I renamed the class and file to "fred" and disabled one inner class, which did then work. The error was misleading in that the class name and filename WERE identical - it was the case of the filename passed to javac that was different to the actual classname/filename.

thanks anyway - your comment did help me remove that compiler limitation possibility. I'm thinking of sending this case thing into Sun as a javac bug if I can recreate it.



0
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 2816657
Good luck!

Laminamia :)
0
 

Author Comment

by:simonm99
ID: 2817423
yes, I recreated it, and yes I reported it. It amazes me that this got through testing.
0
 

Author Comment

by:simonm99
ID: 2843899
they said it was "Usage error" because their compiler can't deal with case differences in parameters.
They said "Windows is one of the few OSs that doesn't pay attention to case, your problem is a usage error"

muppets.
0
 
LVL 3

Expert Comment

by:Laminamia063099
ID: 2844406
Gotta love Microsoft :)

Laminamia
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question