This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: listener problems