This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to close the current jframe?  RSS feed

 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Following is the code on the click of a button, id like to know how do i close the current jframe on which the jButton4 is currently placed. I know how to send it to the next Jframe i.e JobCard. But need to close the current one. I tried using this.setVisible(true); But it does not work.




Thank You.
Regards,
Yuta Lolap.
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to send it to the next Jframe i.e JobCard.


Maybe a better approach is to use a CardLayout and just display a different panel in the current frame. Users don't like frames hiding and showing. Read the section from the Swing tutorial on How to Use CardLayout for more information and examples.

Any to answer your question you can use the SwingUtilities.windowForComponent(...) to get the frame for the button. You can get the button from the ActionEvent.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!