Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

CardLayout not updating display of card until event handler exits

I have a dialog that contains a panel with a CardLayout.  This panel contains two child panels that I need to be able to switch between upon pressing a dialog button.  However, when I call CardLayout.show() in the button's "action performed" handler, nothing (visual) happens!  Only after
the event handler exits does the display get updated with the selected card.  This is a real problem, because the event handler performs a task that may take several seconds, and the card I'm trying to switch to is supposed to show a progress bar for the task.

Is there any way to get the card layout to update the display immediately from inside the event handler???  I'm using JDK 1.1.6 with Swing components on WinNT 4.0 with JBuilder2.

I've wasted a lot of time trying to find a workaround, but so far I've come up empty handed.  PLEASE HELP!!
0
kfcox
Asked:
kfcox
  • 2
1 Solution
 
sailwindCommented:
Try and invoke the panel's paintAll() method. This will repaint
the panel, along with all of its components. This will hopefully
update the window. Also try to see if repaint will work.

If the code is not too big, you might want to mail us the panel
containing the info.
0
 
sailwindCommented:
below is an example of my updateWindow method for my panel:

        public void updateWindow(String ip, String function) {

// card is the cardpanel object that I set as layout manager
// contentPanel is the contentpanel to draw with
// data is the subpanel that I want to show right now.

            card.show(contentPanel, "data");

            String[] colNames;
            setTitle("PIX "+ip+" "+function+" Information");
            datapanel.setTitle(function);
           
            paintAll(this.getGraphics());            
        }

do a paintAll, and the screen should be updated.

Please ask if you have any further questions.
0
 
kfcoxAuthor Commented:
That did the trick!  THANKS!!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now