wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Question on Action Listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on Action Listeners" Watch "Question on Action Listeners" New topic
Author

Question on Action Listeners

Ryan Maxwell
Greenhorn

Joined: Mar 21, 2006
Posts: 7
Hey!

Quick question on action listeners...

I have a program that starts with a main frame and then creates new frames as buttons are pressed. Is it possible to set an action listener that will cause the main frame to respond to button presses within the created frames?

-Thanks!
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Sure. Just use a reference to the main frame as the action listener as long as it implements ActionListener.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"Saint Apathy,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names.

You can edit your name here.

Thank you for your prompt attention, and enjoy the ranch!

-Marc


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ryan Maxwell
Greenhorn

Joined: Mar 21, 2006
Posts: 7
Okay, thanks!
What do you mean a reference to the main frame?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Well you have to send a reference to an ActionListener to the method setActionListener.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Ryan Maxwell:
... What do you mean a reference to the main frame?

I think Keith is suggesting something like this: Suppose you define a class MainFrame that extends JFrame and implements ActionListener. Then...

(Thanks for changing your display name so quickly!)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Action Listeners
 
Similar Threads
breaking out of frameset upon Actionforward
how can i include a JSP in an HTML page?
session management -cookie disabled
small application
targeting frames