Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pointer to function??

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
This may sound stupid, but is there a way to point to a function in java.. for example... (using swing) I have a JDialog that is a generic dialog to allow uses to make a choice, yes to an action, no. I want to be able to use this dialog for any choice. So the 'yes' button has to have a dynamic (???) action listener.. Does this make any sense.. and is it possible (I know C++ has pointer to functions)?


Thanks, appreciate any help
 
Nevermind, I think I got it... I can just pass the action listener to the dialog... that's pretty neat
 
btw, if you are interested, the answer to your original question is yes. Function pointer functionality can be achived via reflection. Method name or id can be passed to an object and via reflection, an object can instantiate a class and or execute a method. Take a look at the Sun tutorial.

Dix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top