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

100% of CPU usage with JScrollPane in JScrollPane

XMLWordPrintable



      Name: gm110360 Date: 09/28/2004


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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If you add a JScrollPane Y in a JFrame, then add a JScrollPane X in the JScrollPane Y and then add a JPanel Z in the JScrollPane X and set the preferred size of the JPanel to something a little bit smaller then the size of the JScrollPane Y, scroll bars appears and the CPU goes to 100% of usage if you resize the JFrame.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      -Create a JFrame.
      -Set a null layout to the content pane of the JFrame.
      -Create a JScrollPane Y and set its bounds.
      -Add the JScrollPane Y in the JFrame.
      -Add a JScrollPane X in the JScrollPane Y.
      -Add a JPanel A in the JScrollPane X.
      -Add a JPanel B in the JScrollPane A.
      -Set the preferred size of the JPanel B to something a little bit smaller then the size of the JScrollPane Y.
      -Show the JFrame. (There should not be any scroll bars).
      -Resize the JFrame.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Nothing special. Just the JFrame being resize. The JScrollPane should not be affected there should not be scroll bars added.
      ACTUAL -
      Scroll bars appear and the CPU goes to 100% of usage

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class TestPlayer {
          public static void main(String args[]) {
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.getContentPane().setLayout(null);
              JScrollPane zone = new JScrollPane();
              zone.setBorder(null);
              zone.setSize(new Dimension(400,400));
              zone.setLocation(20,20);
              JScrollPane player = new JScrollPane();
              player.setBorder(null);
              JPanel background = new JPanel();
              background.setBackground(Color.BLACK);
              JPanel video = new JPanel();
              video.setBackground(Color.BLUE);
              video.setPreferredSize(new Dimension(390,389));
              background.add(video);
              player.setViewportView(background);
              zone.setViewportView(player);
              frame.getContentPane().add(zone);
              frame.setSize(500,500);
              frame.show();
          }
      }
      ---------- END SOURCE ----------
      (Incident Review ID: 315572)
      ======================================================================

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: