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

Displaying a JDialog after a second Frame is shown is slow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6
    • client-libs
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0_10-rc2"
      Java(TM) SE Runtime Environment (build 1.6.0_10-rc2-b32)
      Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)



      ADDITIONAL OS VERSION INFORMATION :
      SunOS cfsc.pbn.bnl.gov 5.7 Generic_106541-46 sun4u sparc SUNW,Ultra-60
      or
      Linux acnlin04.pbn.bnl.gov 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The slowness effect is worse on SUN but is also apparent on LINUX.

      A DESCRIPTION OF THE PROBLEM :
      Version 1.5 and prior had no problems when displaying a Dialog window after a second JFrame was made visible. With 1.6 and later this problem has been persistent. I believe I sent a bug report previously but no solution was ever provided.

      The only way to show this problem is to run the sample program I have supplied. The problem seems to be significantly worse when running on a SUN but it is still apparent from linux. I have not tried other operating systems.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the program I supply and click the "show dialog" button. Notice the fast response. Then click the "show frame" button and then click the "show dialog". Notice how much longer it takes for the dialog to show in this case. This problem is actually magnified when you have a more complicated user interface involved.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The performance should not be different no matter how many frames are visible. This is the case in release 1.5 and earlier.
      ACTUAL -
      The slowness I explained above.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No errors

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;

      import java.awt.event.*;
      import java.awt.*;

      /* Simple program to show how displaying a dialog window when a second jframe
         is displayed is very slow on SUN and LINUX */
      public class Slow extends JFrame {

          public static void main(String args[]) {

              for (int i=0; i<args.length; i++)
                  System.out.println(args[i]);

      // Slow is the "main" window
              Slow s = new Slow();
              s.setVisible(true);
          }

          public Slow() {
              enableEvents(AWTEvent.WINDOW_EVENT_MASK);
              JPanel panel = (JPanel) getContentPane();
              panel.setLayout(new GridLayout());
              panel.add(_button1);
              panel.add(_button2);
                
              _button1.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          if (_frame2 == null)
      _frame2 = new Frame();
                          _frame2.setVisible(true);
                      }
                  });

              _button2.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          if (_dialog == null)
      createDialogWindow();
      _dialog.setVisible(true);
                      }
                  });
              
              pack();
          }

          public void createDialogWindow() {
      _dialog = new JDialog(this);
        Container content = _dialog.getContentPane();
        content.add(new JLabel("Dialog Window"));
      // setModal seems to cause all the problems
        _dialog.setModal(true);
      _dialog.pack();
          }

          JButton _button1 = new JButton("Show Frame");
          JButton _button2 = new JButton("Show Dialog");
          JDialog _dialog = null;
          JFrame _frame2 = null;

          class Frame extends JFrame {
              public Frame() {
                  enableEvents(AWTEvent.WINDOW_EVENT_MASK);
                  
                  JPanel panel = (JPanel) getContentPane();
                  JLabel l = new JLabel("Click 'Show Dialog' and response to click is slow");
                  panel.add(l);

                  pack();
              }
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      I have found no work around.

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: