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

Scrollbar thumb disappears when display list is large

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8u60, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Introduced In Build:
      b61
    • Introduced In Version:
      9
    • CPU:
      x86
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Using the Nimbus look and feel. If a ComboBox or Scrollpane has a large amount of data to scroll in relation to the amount that is view able the slider thumb disappears. This does not happen for the Metal look and feel.

      REGRESSION. Last worked in version 8u51

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run attached program.
       A window with 4 combo boxes will appear. The top combo box allows select of the Nimbus or Metal look and feel. The other 3 combo boxes contain the same list of data. Each of the 3 has setMaximumRowCount set to a different value(7,8,9).


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected that the slider thumb would always display.
      ACTUAL -
      when Nimbus is selected:
      Combo Box 2 will not display a slider thumb.
      Combo boxes 3 & 4 will display a slider thumb.

      When Metal is selected:
      Combo boxes 2, 3 & 4 will display a slider thumb.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
       *
       * Redistribution and use in source and binary forms, with or without
       * modification, are permitted provided that the following conditions
       * are met:
       *
       * - Redistributions of source code must retain the above copyright
       * notice, this list of conditions and the following disclaimer.
       *
       * - Redistributions in binary form must reproduce the above copyright
       * notice, this list of conditions and the following disclaimer in the
       * documentation and/or other materials provided with the distribution.
       *
       * - Neither the name of Oracle or the names of its
       * contributors may be used to endorse or promote products derived
       * from this software without specific prior written permission.
       *
       * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
       * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
       * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
       * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       */

      //package components;

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.UIManager.*;

      /*
       * CustomComboBoxDemo.java uses the following files:
       * images/Bird.gif
       * images/Cat.gif
       * images/Dog.gif
       * images/Rabbit.gif
       * images/Pig.gif
       */
      public class CustomComboBoxDemo extends JPanel {
          ImageIcon[] images;
          String[] petStrings = {"Bird", "Cat", "Dog", "Rabbit", "Tom", "Dick", "Harry", "Marina", "Lena", "Katherine", "Bird", "Cat", "Dog", "Rabbit", "Tom", "Dick", "Harry", "Marina", "Lena", "Katherine", "Pig","Bird", "Cat", "Dog", "Rabbit", "Pig","Bird", "Cat", "Dog", "Rabbit", "Pig"};
      String[] lookAndFeel = {"Nimbus", "Metal"};
      JComboBox<String> ui = new JComboBox<String>(lookAndFeel);
      static JFrame frame = null;
          /*
           * Despite its use of EmptyBorder, this panel makes a fine content
           * pane because the empty border just increases the panel's size
           * and is "painted" on top of the panel's normal background. In
           * other words, the JPanel fills its entire background if it's
           * opaque (which it is by default); adding a border doesn't change
           * that.
           */
          public CustomComboBoxDemo() {
              // super(new BorderLayout());
      super();

      this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
              //Create the combo box.
              JComboBox<String> petList1 = new JComboBox<String>(petStrings);
              JComboBox<String> petList2 = new JComboBox<String>(petStrings);
              JComboBox<String> petList3 = new JComboBox<String>(petStrings);
              // JComboBox<String> ui = new JComboBox<String>(lookAndFeel);


      //start

      // Specify the look and feel to use by defining the LOOKANDFEEL constant
      // Valid values are: null (use the default), "Metal", "Nimbus", "Motif"
          
      ui.addActionListener(new ActionListener(){//add actionlistner to listen for change
                  @Override
                  public void actionPerformed(ActionEvent e) {

                      String s = (String) ui.getSelectedItem();//get the selected item
      try{
      setLookAndFeel(s);
      }
      catch (UnsupportedLookAndFeelException excpt) {
      // handle exception
      }
      catch (ClassNotFoundException excpt) {
      // handle exception
      }
      catch (InstantiationException excpt) {
      // handle exception
      }
      catch (IllegalAccessException excpt) {
      // handle exception
      }
                  }
              });

      //end


              // ComboBoxRenderer renderer= new ComboBoxRenderer();
              // renderer.setPreferredSize(new Dimension(200, 130));
              // petList.setRenderer(renderer);
              petList1.setMaximumRowCount(7);
      petList1.setBounds(5,5,120,30);

      petList2.setMaximumRowCount(8);
      petList2.setBounds(5,40,120,30);

      petList3.setMaximumRowCount(9);
      petList3.setBounds(5,80,120,30);


              //Lay out the demo.
      this.add(ui);
              this.add(petList1);
              this.add(petList2);
              this.add(petList3);

              // setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
          }

      private void setLookAndFeel(String theme) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException{
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
      if (theme.equals(info.getName())) {
      System.out.println("Look and feel: " + theme);
      if(theme.equals("Metal")){
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      }
      else {
      UIManager.setLookAndFeel(info.getClassName());
      }
      SwingUtilities.updateComponentTreeUI(frame);
      frame.pack();
      }
      }
      }

          /** Returns an ImageIcon, or null if the path was invalid. */
          protected static ImageIcon createImageIcon(String path) {
              java.net.URL imgURL = CustomComboBoxDemo.class.getResource(path);
              if (imgURL != null) {
                  return new ImageIcon(imgURL);
              } else {
                  System.err.println("Couldn't find file: " + path);
                      return null;
              }
          }

          /**
           * Create the GUI and show it. For thread safety,
           * this method should be invoked from the
           * event-dispatching thread.
           */
          private static void createAndShowGUI() {
              //Create and set up the window.
              frame = new JFrame("CustomComboBoxDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              //Create and set up the content pane.
              JComponent newContentPane = new CustomComboBoxDemo();
              newContentPane.setOpaque(true); //content panes must be opaque
              frame.setContentPane(newContentPane);

              //Display the window.
              frame.pack();
              frame.setVisible(true);
          }

          public static void main(String[] args) {
      try {
                  // Set cross-platform Java L&F (also called "Metal")
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
      if ("Nimbus".equals(info.getName())) {
      UIManager.setLookAndFeel(info.getClassName());
      break;
      }
      }
      }
      catch (UnsupportedLookAndFeelException e) {
      // handle exception
      }
      catch (ClassNotFoundException e) {
             // handle exception
      }
      catch (InstantiationException e) {
             // handle exception
      }
      catch (IllegalAccessException e) {
             // handle exception
      }

              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI();
                  }
              });
          }

       
      }

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ssadetsky Semyon Sadetsky (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: