JDK-7171632 : JToolbar with JTextField does not layout its components correctly using Nimbus
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86
  • Submitted: 2012-05-24
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
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 ----------

Comments
- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014