🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12678

Changing panels within a frame

#12678
From: Matt Stauffer
Date: Sun, 22 Nov 1998 00:00
44 lines
2419 bytes
I'm having trouble displaying different panels within one frame.

What I'm trying to do is display several screens of info (user makes one
or two selections on each screen), very similar to say what happens when
you install a program with InstallShield. What I want to do is have a
frame with several panels. When I first create the frame I also create
the first panel and display it on the frame. Once the user clicks the
"Next >>" button I want to remove the first panel and then put the
second panel in its place on the frame and trash the first panel (I
figured this would be better then trashing the whole frame and creating
a whole new frame).

Here's the pertinent parts of the code (from the frame class):

       // adding the first panel
        this.getContentPane().add( introPanel, BorderLayout.CENTER );
        . . .

      // remove the first panel and replace it with the second
      this.getContentPane().remove( introPanel );
      introPanel = null;
      projectPanel = new ProjectPanel( this );
       this.getContentPane().add( projectPanel, BorderLayout.CENTER );
       // I don't know if repaint is necessary but call it just to be
safe.
        repaint();

What is currently happening is it displays the first panel properly,
when I click the "Next >>" button it prints out the debugging message in
my event handler and it appears to remove the first panel, but it
doesn't display the second panel. It just shows an empty frame. If I
display the second panel when I start up the program it displays
properly so my two panels seem to be okay.

I think I've done something similar to this with AWT before, but it
doesn't seem to work for me now. Is there something else unique to Swing
that I'm doing wrong here? Am I just missing something blatantly
obvious, or just doing something incredibly stupid?

Thanks for any help.

--
Matt Stauffer
matts@jmaca.com
Technical Details
Message-ID: <3658C12C.DA95AA40@jmaca.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,facde98a621e3092,start
X-Google-Attributes: gid111d45,public
From: Matt Stauffer <matts@jmaca.com>
Subject: Changing panels within a frame
Date: 1998/11/22
Message-ID: <3658C12C.DA95AA40@jmaca.com>
X-Deja-AN: 414653507
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: J'maca Software
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing