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.
posted 2 years ago
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.