Access JFrame Components from JDialog

Hi, Can anyone help me, I created a form (which extends JFrame) that collects details like name, address, etc and has a button such that when i click the button, it brings up a JDialog that contains a list of names retrieved from a database. What i want to do is that when i click/double click one of the names, in the JDialog, the info about the person gets loaded in the respective components in the JFrame. I have the JDialog working and retrieving the info in the database is working but how to load - for example the name of the person in the JTextfield which is a component in the Jframe. thanks.

Well, you have several options. 1. Since your textfields are private you need to create public setter methods for them in your JFrame class. Then call those methods from your JDialog class. So you would have methods like the following in your JFrame

2. Make your textfields public static and just dot reference them through your JFrame object you passed to your JDialog 3. Add 2 more params to your JDialog constructor and pass your JTextField objects to your JDialog and access them that way.

All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad: