Solved

CardLayout not updating display of card until event handler exits

Posted on 1998-08-26
3
295 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet requestdispatcher include and forward differences 1 39
session migration servlets 2 42
HashTable highest marks enumeration alternative 9 43
ejb example issues 3 28
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

827 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