JToolbar with JTextField does not layout its components correctly using Nimbus

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.7.0_01"
      Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
      Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      RHEL 5 (Linux 2.6.18-262.el5 x86_64 GNU/Linux)

      A DESCRIPTION OF THE PROBLEM :
      When using the Nimbus Look And Feel, the JButton in a JToolBar setup as follows should be visible:
      JToolBar
             JTextField (with columns = 20)
             Horizontal Glue
             JButton

      However, the JButton is not visible as the layout manager for the tool bar does not correctly account for the width of the text field.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the test case using the Nimbus Look And Feel.
      Execute the test case using the Metal Look And Feel.
      Compare the results. The button is visible in Metal and not visible in Nimbus.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The JButton should be inside the viewable portion of the JToolBar.
      ACTUAL -
      The JButton is not visible within the viewable portion of the JToolBar.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class TextFieldTest extends JFrame
      {
          public TextFieldTest()
          {
              // Create the text field
              JTextField textField = new JTextField( 20 )
              {
                  @Override
                  public Dimension getMaximumSize()
                  {
                      return super.getPreferredSize();
                  }
              };
              
              // Create the tool bar
              JToolBar toolBar = new JToolBar();
              toolBar.add( textField );
              toolBar.add( Box.createHorizontalGlue() );
              toolBar.add( new JButton( "Button" ) );
              
              // Layout the frame
              getContentPane().setLayout( new BorderLayout() );
              getContentPane().add( toolBar, BorderLayout.NORTH );
              setPreferredSize( new Dimension( 800, 600 ) );
              pack();
          }
          
          
          public static void main( String[] args )
          {
              SwingUtilities.invokeLater( new Runnable()
              {
                  public void run()
                  {
                      TextFieldTest test = new TextFieldTest();
                      test.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
                      test.setVisible( true );
                  }
              } );
          }
      }

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

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: