• Post Reply Bookmark Topic Watch Topic
  • New Topic

closing jframe with button question.

 
Kevin Pang
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is a JFrame A with a button on it, after click A the JFrame B will be open
how to close the JFrame B when I click a "close" button on B and then show the JFrame A?
Thanks in advance.
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the dispose() method sound familiar? You may also want to set the default close operation to JFrame.DISPOSE_ON_EXIT.
 
Kevin Pang
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you. already solved.
just use these codes:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
this.mainwin.setEnabled(true);
frame.setVisible(false);
frame.dispose();

}
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that when you showed frame B you disabled frame A. Perhaps you should use a modal JDialog instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!