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

JDialog/JPanel partially displays contents under OpenWindows




      Under JDK 1.2, when displayed under OpenWindows, the included test case
      will incorrectly display the buttons contained within the JPanel. The
      first time it displays, it may be correct. However, if the dialog is
      dismissed (either via the window manager header or by hitting the
      "Quit" button), then the next time it displays, one of the buttons will
      disappear to leave a light blue background in its place. On subsequent
      displays, more buttons will disappear and the remaining ones will slide
      down within the window. After multiple iterations of dismissing and
      recreating, all of the buttons will be gone, leaving only the blue

      This problem will occur consistently under OpenWindows, but it
      behaves correctly under CDE.

      Another apparent requirement is that it only occurs on systems with
      256MB or more of memory. This problem has been recreated on 4 different
      systems with 256MB or greater of physical memory. Conversely, I was
      not able to recreate it on several other machines with the same
      OS+patches, but which had 64MB or 128MB of memory. [Obviously this
      might just be a coincidence, but it seemed unlikely enough to be
      worth mentioning.]

      I've attached a small jpeg snapshot of 5 successive cycles of popping
      up the JPanel and dismissing it, to show the shifting and eventual
      disappearance of the contents.

      I've recreated this with multiple JDKs, including:

          java version "1.2.2"
          Classic VM (build JDK-1.2.2-001, green threads, sunwjit)
          java version "java1.2"
          Solaris VM (build Solaris_JDK_1.2_01_dev05_fcsK, native threads, sunwjit)

      To compile and run the test case:

          % javac Test.java
          % java Test

      The test case is:

      //--------------- Test.java
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.border.*;

      public class Test extends JPanel {
          private static JFrame f = null;
          private JDialog td = null;

          public Test() {
              this.setLayout(new BorderLayout());
              this.setBorder(new EmptyBorder(30,30,30,30));
              JButton jb = new JButton("click here");
              jb.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) { dofile(); }
              this.add(jb, BorderLayout.CENTER);

          protected void dofile() {
              if (td == null)
                  td = new TDialog();

          private class TDialog extends JDialog {
              JPanel p;
              JButton b;
              TDialog() {
                  p = new JPanel(new GridLayout(4,0));
                  for (int i = 0; i < 3; i++) {
                      b = new JButton(String.valueOf(i));
                  b = new JButton("quit");
                  b.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent e) { cancel(); }
              void cancel() {

          public static void main(String argv[]) {
              f = new JFrame("Test");
              f.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) { System.exit(0); }
              Test t = new Test();

              Dimension dm = Toolkit.getDefaultToolkit().getScreenSize();
              Dimension dt = f.getSize();

              // centered on the screen to start
              f.setLocation(dm.width/2-dt.width/2, dm.height/2-dt.height/2);




            amfowler Anne Fowler (Inactive)
            duke J. Duke
            0 Vote for this issue
            0 Start watching this issue