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 Passing data from child JDialog to parent JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Passing data from child JDialog to parent JFrame" Watch "Passing data from child JDialog to parent JFrame" New topic
Author

Passing data from child JDialog to parent JFrame

Sanjoo Singh
Ranch Hand

Joined: May 08, 2010
Posts: 33
Hi All,

I have a requirement to read details on a JDialog (called program) and then returning back to parent JFrame (calling program) so that details can be added to into a JTable (which is on JFrame) . Any help on how to pass data from JDialog to parent JFrame. I think making JTable "public static" is an option. However I would like to understand if any other better option can be drawn.

Thanks.


Solution Spider
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

The usual way is to use one of the JOptionPane.showXXXDialog(), some of which return a value. Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html
This would sit better on the GUI forums. Moving....


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Sanjoo Singh
Ranch Hand

Joined: May 08, 2010
Posts: 33
My data form is bit complex, so can not use JOptionPane.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

JOptionPane lends itself easily to complexity.
If you notice, the showInputDialog, in its many forms, accepts an Object message. You can leverage on this to create any complex UI container and pass it on to the message.

Does your requirement make it still impossible for you to useJOptionPane? If yes, maybe you can tell us why you think so and we can try and help you.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
You ought not to pass information to the frame. You should be passing information via the frame to your application. The difference may appear slight, but it is actually very important.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing data from child JDialog to parent JFrame