JDK-5061421 : REGRESSION: JTabbedPane.setBackground() has no effect when the pane is empty
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-06-10
  • Updated: 2004-06-14
  • Resolved: 2004-06-14
Related Reports
Relates :  
Relates :  
Description

Name: rmT116609			Date: 06/10/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b40)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b40, mixed mode)

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

EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows look&feel is used.

A DESCRIPTION OF THE PROBLEM :
When a background is set to an empty JTabbedPane, it is ignored and the JTabbedPane is displayed as white. Calling setOpaque(true) does not help.
When a tab is added to the JTabbedPane, the background is correctly displayed next to the tab, but after the tab is removed, the tabbed pane reverts back to white.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Copy it into a file called "TestJTabbedPane.java", compile and run on both JDK 1.4.2 and JDK 1.5 and compare the results. The background color is taken into account only on JDK 1.4.2.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JTabbedPane should be painted in MAGENTA color.

ACTUAL -
The JTabbedPane is painted in white color.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
   public class TestJTabbedPane {
   
    public TestJTabbedPane() {
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (Exception exc) {
            exc.printStackTrace();
        }
        javax.swing.JFrame frame = new javax.swing.JFrame();
        frame.setSize(300, 200);
        javax.swing.JTabbedPane tabPane = new javax.swing.JTabbedPane();
        
tabPane.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
        frame.getContentPane().setLayout(new java.awt.GridBagLayout());
        java.awt.GridBagConstraints constraints = new 
java.awt.GridBagConstraints();
        constraints.fill = constraints.BOTH;
        constraints.weightx = 1.0;
        constraints.weighty = 1.0;
        frame.getContentPane().add(tabPane, constraints);
        tabPane.setBackground(java.awt.Color.MAGENTA);
        frame.show();
    }
   
}


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

Release Regression From : 1.4.2_04
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 277065) 
======================================================================

Comments
EVALUATION Name: sh120115 Date: 06/11/2004 Everything is fine on Windows NT 4. I assume therefore that the submitter is reporting this against Windows XP only. ###@###.### 2004-06-11 ====================================================================== It is up to each L&F implementation to decide whether to respect the various properties in a JComponent. All properties do not apply to all L&F implementations. For JTabbedPane, the Windows L&F on XP uses a background image to which a single background color can not be applied. See evaluations for bug reports 4862679 and 5047032. ###@###.### 2004-06-14
14-06-2004