File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes listener problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "listener problems" Watch "listener problems" New topic

listener problems

aron beal

Joined: Sep 29, 2003
Posts: 2
Hello the forum,
I'm in the midst of writing a simple Animator, and I'm having listener problems. The following is a method that adds a "Frame" to the end of an "Animation". The class that this is in extends JPanel, and the Frame class for the moment extends JButton Implements MouseListener.
public void addFrame(Image i){
if(i != null){
Frame temp = new Frame(i,(length()+1)+"");
System.out.println("width: "+temp.getImageWidth()+", height: "+temp.getImageHeight()+", "+length()+" frames total");
if (playhead_position < 0) {
playhead_position = 0;
Mouse events are not being heard by my "Frames". Now, these Frame(JButton) objects are nestled in the Animator(Jpanel) which is nestled within a JScrollPane which is inside of a JFrame. My question is, does the external JFrame or JScrollPane need to know that the Animator has objects that are listening for mouse events, or is it enough for the Animator itself to know?
Thanks in advance,
aron beal

Joined: Sep 29, 2003
Posts: 2
Never mind, I figured it out. The answer was "yes indeedy, it is enough for just the Animator to know". I attached an anonymous mouselistener to the Frame object, and it registered nicely.
[ September 29, 2003: Message edited by: aron beal ]
I agree. Here's the link:
subject: listener problems
It's not a secret anymore!