• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Event handling

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
This is the first time I am posting a query.
The class Test.java is returning error as:
Interface MouseListener of class text not found

Now, I don't understand if the problem is with my code or with my jdk.
Please, help me out.

ps:
Pl use the [ code ] and [ / code ] tags, without the spaces, when posting soruce code. thanks.
- satya
[ January 24, 2002: Message edited by: Madhav Lakkapragada ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, buddy, I think you probably should go to check whether you have typed correctly the name of the listener interface.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you should import java.awt.event.MouseListener interface too !
And be careful, you wrote MouseListner, don;t forget the "e" that comes after the "t" in MouseListener, otherwise it won't compile...
Moreover, we'd like you to read the Javaranch Naming Policy and register again.
Thank you,
HIH
[ January 24, 2002: Message edited by: Valentin Crettaz ]
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you already got an answer for this ina different forum.
u should import:
import java.awt.event.*;
and the the AWTEvent thingie...
if ull look there ull see the MouseListener interface is defined in the java.awt.event package.
 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need this one import java.awt.event.*;
but you don't need this one setVisible(true);
(required for frames not applets)
 
Pat
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roy,
After having corrected the spelling as well as adding java.awt.event the program still gives the same error.
Could you please compile and tell me if it is compiling at your end.
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. i just tried to run at it at my end and here is what u got to do:
1) change this line :
import java.AWTEvent at the start to this:
import java.awt.event.*;
2) correct the type of the implements MouseListner
to:
implements MouseListener
3) correct the typo
public void mouseRealeased(etc..)
to:
public void mouseReleased(etc...)
4) you have a problem using the add method
inside the mouse Clicked!
the problem is u cant use the add method inside class text. u can only use it in class that u have your Frame. so either use the text class as inner class OR use a constructor to pass the frame refrence to the text class using:
text tt=new text(this);
in the creation.
hope it helps
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Does it really matter a lot? If so, I will register again


There is a standard we would like to keep, so we would be glad if you register again.
Thank you very much for your cooperation
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for registering but you still don't comply with the policy...
I don't wanna sound picky but I didn't make the rules...
Thank you for your cooperation and we hope you enjoy your time at Javaranch
 
reply
    Bookmark Topic Watch Topic
  • New Topic