Matthew,

I have some very similar code which I wrote some time
ago.  Looking back at it I seem to have taken a belt
and braces approach.  It looks a bit over the top now
looking back at it but it works without any long delays!
I call repaint on the newly added wizard pane, and it's
(new) parent, then I call revalidate on the parent. 

It sounds as if you're very close to the same solution
anyway.  The revalidate method is the key. It still 
exists; see the API javadoc on JComponent. 

Regards

Dave Wathen
Goldman Sachs Asset Management
3rd Floor, Procession House
55 Ludgate Hill
London EC4M 7JN
+44 (0)20-7774-2998

It is not necessary to understand things in order to argue about them.
(Caron de Beaumarchais)


-----Original Message-----
From: Matthew Bloch [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 01, 2001 12:29 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Update question


Hello; hope this is the correct list to use, I've done plenty of Swing
programing before and not found a problem with it, so I feel like I'm okay
on the basics.  Can you keep the Cc: line intact when replying, as I'm not
a subscriber?  cheers...

Anyhow, it's an problem to do with changing window components, but windows
not updating.  I'm not sure why, since I've apparently done everything by
the book.  I've written a class which extends JFrame and changes one of
its panels in response to button clicks (an MS-style `Wizard').  In the
button click event handler, I fire off this function which updates the
window's state:

---------------------8<------------------------------------------
  private void updateState() {

    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        if (current != null)
          topPanel.remove(current);

        current = (WizardQuestion) sequence.whichState();
        current.setPreferredSize(new Dimension(360, 384));
        current.preDisplay();
        topPanel.add(current, BorderLayout.CENTER);
        descText.setText(current.descriptive());
        descText.setEditable(false);
        descText.setBackground(Color.lightGray);
        setTitle(title+" : "+current.title());

        if (sequence.isLast())
          nextButton.setText("Finish");
        else
          nextButton.setText("Next >");

        if (sequence.isFirst())
          prevButton.hide();
        else
          prevButton.show();
        invalidate();
        repaint();
      }
    });
  }
---------------------8<------------------------------------------

and the window doesn't update immediately, usually taking 4-5 seconds.
I've tried various combinations of invalidate(), repaint() on both the
JFrame and its contentPane , but nothing makes it update My understanding
was that this code executes in a `safe' part of the Swing event loop where
these effects wouldn't be apparent.  I also notice there's a widely
documented revalidate() method for components which seems to be absent
since Swing 1.3.  Can anybody fill me in?

cheers,

-- 
Matthew       > http://www.soup-kitchen.net/
              > ICQ 19482073

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to