• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to close the current jframe?

 
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: 2699
10
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!