This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing a JFrame once the data is submitted

 
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
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!