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

REGRESSION: JDesktopPane setVisible(true) need before adding JInternalFrames

XMLWordPrintable

    • 1.2.2
    • generic, x86, sparc
    • generic, solaris_2.6, windows_95, windows_nt



      Name: clC74495 Date: 09/28/98


      JDesktopPane simply _does not work_ in Swing 1.1 beta 3. This problem
      exists for all Look and Feels, including our own custom one. JInternalFrames
      added to the desktop pane using .add() never show up.

      This problem does not exist in Swing 1.0.2.

      Simply by commenting out the javax.swing line and uncommenting the
      com.sun.java.swing one (and changing the classpath), the following
      example works in Swing 1.0.2/1.0.3. It fails very obviously in Swing 1.1
      (the JInternalFrame never shows up).

      This problem also has the very odd side effect of causing Look and Feel
      initialization done around the same time as the .add() to fail.

      We've traced though JLayeredPane.addImpl() and the JInternalFrame is
      being added (and is in a correct layer, and is the only component in the
      JDesktopPane), so we're stumped as to what is going wrong. The only
      workaround we've found is removing the JDesktopPane and adding the
      JInternalFrame directly to a panel, which is awful.

      It would be _very, very_ bad if something this widely used and so
      basic was broken in the public release of 1.1b3.

      package jfilechooser;

      import java.awt.*;
      //import com.sun.java.swing.*;
      import javax.swing.*;

      public class MyClass1 extends JFrame {

        public MyClass1() {
          JDesktopPane jdp = new JDesktopPane();
          this.getContentPane().add(jdp, BorderLayout.CENTER);
          JInternalFrame jif = new JInternalFrame("A Frame");
          jdp.add(jif, JDesktopPane.DEFAULT_LAYER);
          try
          {
            jif.setMaximum(true);
          }
          catch (java.beans.PropertyVetoException pve)
          {}
          
          jif.setVisible(true);
        }

        public static void main(String[] args) {
          MyClass1 myClass1 = new MyClass1();
          myClass1.setSize(640,480);
          myClass1.setVisible(true);
        }
      }
      (Review ID: 39415)
      ======================================================================

            hgajewsksunw Hania Gajewska (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: