Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

When .setVisible(false) just won't work...

843805Apr 19 2007 — edited Apr 20 2007
First off, I'd like to appologize for the original post I made about this... As I realized all too late that it was too long, that being said...

I'm trying to create an application that basically contains two frames ( for purposes of this explanation ). The first frame contains one button with an ActionListener that opens a new window/frame:
public class FirstFrame extends JFrame { 

     public FirstFrame() {
         super( "First" );
         setLayout( new FlowLayout() );
          
         JButton btn = new JButton(  "remove frame" );
         btn.addActionListener( new ActionListener() {
              public void actionPerformed( ActionEvent ae ) {
                   closeThisWindow(); 
         }
         } );
         add( btn, SwingConstants.CENTER );
     }

     private void closeThisWindow() {
          SecondFrame frame = new SecondFrame();
          GUIKit a = new GUIKit();
          a.iniJFrame( frame );

          this.setVisable( false ); 
     }
}// end of class 
This works fine except that when the button is pushed both frames are visible, with the first one being completely blank and the second frame under it. To remove that first frame I've tried:

this.setVisable( false );
this.getParent().setVisable( false) ~ this returns a NullPointerException;
this.enable(false) ~ this really doesn't do anything.
and this.hide() which is depreacated... and doesn't work either

It just doesn't want to remove that window/frame... Any ideas? Or, am I just missing something completely?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2007
Added on Apr 19 2007
5 comments
1,462 views