• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Java Forms and Subforms  RSS feed

 
Svetlana Rosemond
Greenhorn
Posts: 17
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a parent form and a sub-form for my application. Now, in my button handler to open the sub form, I have the following code:



My Sub form:







My problem is, when I call the sub-form the parent form doesn't wait until the sub-form is closed, it attempts the set the text of jtextfield3, however, it throws a nullpointerexception because the retrieveAuthor object isn't fully created yet. How would I properly call my subform and then when the form is closed set the jTextField with my Author object?

I attempted to set the sub-form visibility to false and then check it in my main form, but that didn't work.
 
Rob Camick
Ranch Foreman
Posts: 2821
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use a JFrame as the sub form.

Instead you need to use a "modal" JDialog.

 
Fred Kleinschmidt
Bartender
Posts: 567
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or use a JOptionPane
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!