• Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing JFrame once data inserted  RSS feed

 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a JFrame form which the user fills in and then clicks on the Create button. I think call my InsertDefect class which gets the data from the fields and enters them into the database.
I need to find a way of closing the Frame once the data has been inserted - the insert query has a result of 1 if this is successful but I am a bit lost on what I can do with this to close the Frame.
The ActionListner code is

I have tried to create an actionlistener method to pass the data and then close the window but the window closes and no data is entered - I expect its because thw window closes before the class can fetch the field data. Anyway if anyone has any ideas about how I can go about this I would be very grateful
Amy
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Not 100% sure I understand how you want this to work, but one quick idea I had was to use a try-catch-finally
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amy, I'm not sure what you mean, but I think you want to know how to close a JFrame gracefully. Building on Ben's answer, we have :

HTH :-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!