File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "listener problems" Watch "listener problems" New topic
Author

listener problems

aron beal
Greenhorn

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)+"");
addMouseListener(temp);
add(temp);
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
aron beal
Greenhorn

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.
AB
[ September 29, 2003: Message edited by: aron beal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: listener problems