Solved

CardLayout not updating display of card until event handler exits

Posted on 1998-08-26
3
289 Views
Last Modified: 2010-03-30
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
Comment
Question by:kfcox
  • 2
3 Comments
 
LVL 3

Expert Comment

by:sailwind
ID: 1222624
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
 
LVL 3

Accepted Solution

by:
sailwind earned 300 total points
ID: 1222625
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
 

Author Comment

by:kfcox
ID: 1222626
That did the trick!  THANKS!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now