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

Child panel in JInternalFrame too high with XP style look and feel

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode)

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

      A DESCRIPTION OF THE PROBLEM :
      When using the XP style look and feel on Windows XP, a JPanel added to a JInternalFrame becomes higher than the set preferred size.

      Occurs for Java 1.4.2, 1.5 and 1.6.x

      When running with -Dswing.noxp=true, the panel size is correct

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached example

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected the panel size after pack() to be the preferred size
      ACTUAL -
      The panel in the JInternalFrame is 4 pixels too high

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class SizeTest
      {
         public static void main( String[] args )
         {
            try
            {
               UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
            }
            catch ( Exception e )
            {
               e.printStackTrace();
            }

            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            JDesktopPane dp = new JDesktopPane();
            frame.getContentPane().add( dp );
            frame.setSize( 800, 600 );
            frame.setVisible( true );

            JInternalFrame iFrame = new JInternalFrame();
            JPanel p = new JPanel();
            p.setPreferredSize( new Dimension( 500, 400 ) );
            iFrame.getContentPane().add( p );
            iFrame.pack();
            iFrame.setVisible( true );

            dp.add( iFrame );
            System.out.println( p.getBounds() );
         }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Decrease the internal frame height by 4 pixels after pack
      or use -Dswing.noxp=true

            Unassigned Unassigned
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: