Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6359223

setContentPane doesn't re-validate

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode)

      still repeatable with

      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b51)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b51, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Originally noticed in an application running on Windows 2000. Not reproduced on Linux, but the condensed test I wrote for this bug report also fails on Linux.

      Linux bertha 2.6.12-1-686-smp #1 SMP Tue Aug 16 22:19:38 UTC 2005 i686 GNU/Linux
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      i'm not sure what the real problem is here. that in the actual application, when run on Linux, the display is updated (possibly because of a setJMenuBar)? that setContentPane doesn't imply a need to re-validate? that the documentation doesn't mention this?

      at least one of these things should change. personally, i'd favor having setContentPane do the right thing and cause re-validation.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. save the executable test case to Bug.java
      2. javac Bug.java && java Bug

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      a window should appear with a JLabel; after a second, it should be replaced by a JTextArea.
      ACTUAL -
      the JLabel remains visible until the window is resized.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class Bug extends JFrame {
       Bug() {
        setSize(new Dimension(640, 480));
        setContentPane(new JLabel("Hang on..."));
        setVisible(true);
        new Timer(1000, new ActionListener() {
         public void actionPerformed(ActionEvent e) {
          setContentPane(new JTextArea("Hello, World!"));
          // validate();
         }
        }).start();
       }
       public static void main(String[] args) {
        new Bug();
       }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      uncomment the call to validate.

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: