Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing a JFrame once the data is submitted  RSS feed

 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JFrame which the user can enter details into and then click the submit button. The problem is I can't work out how to close the frame once the data has been input into the database.
I call the ActionListener with

and another class (InsertDefect.java) handles the insertions. A Successful insert returns the number 1 but I can't find a way of extending the AssActionListner so that it Inserts and Closes the window - at the moment I can do either one but not both.
Does anyone know of a way around this?
Thanks
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just need to call dispose() of the frame you need to close. Without seeing the code for InsertDefect it's hard to say where you might want to do this. But I would assume, if InsertDefect has access to the Frame object, you should just be able to do frame.dispose() after you return the 1.
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very very much Gregg
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!