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

Calling getPreferredSize on editable JComboBox messes up Nimbus L&F

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b26
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b14)

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

      A DESCRIPTION OF THE PROBLEM :
      Calling getPreferredSize on an editable JComboBox, when using Nimbus Look & Feel, messes up the layout.

      The submitted test program shows the messed up layout. Leaving the method call to "edit_combo.getPreferredSize()" out solves the layout problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The submitted test program shows the messed up layout. Leaving the method call to "edit_combo.getPreferredSize()" out solves the layout problem.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Editable combo box layout should be correct.
      ACTUAL -
      Editable combo box height is messed up.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class TestNimbus {
        public static void main( String[] args ) throws Exception {
          UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );

          Object[] data = {"Jan", "Piet", "Joris", "Korneel"};

          JComboBox combo = new JComboBox( data );

          JComboBox edit_combo = new JComboBox( data );
          edit_combo.setEditable( true );

          //This line causes layout to be messed up !!! If left out, it works.
          edit_combo.getPreferredSize();

          JToolBar tb = new JToolBar( );
          tb.add( combo );
          tb.add( edit_combo );

          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

          Container content = frame.getContentPane();
          content.setLayout( new BorderLayout() );
          content.add( tb, BorderLayout.NORTH );

          frame.pack();
          frame.setLocationRelativeTo( null );
          frame.setVisible( true );

        }
      }

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

        Attachments

          Activity

            People

            Assignee:
            jasper Jasper Potts (Inactive)
            Reporter:
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: