Solved

CardLayout not updating display of card until event handler exits

Posted on 1998-08-26
3
285 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
Comment Utility
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
Comment Utility
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
Comment Utility
That did the trick!  THANKS!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

763 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

13 Experts available now in Live!

Get 1:1 Help Now