JDK-4690946 : REGRESSION: JTabbedPane.setBackground() and setOpaque() have no effect
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-05-24
  • Updated: 2015-05-14
  • Resolved: 2003-04-25
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
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: gm110360			Date: 05/23/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-

b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version

5.00.2195]

A DESCRIPTION OF THE PROBLEM :
setBackground for JTabbedPane instances seems to have no effect.

setOpaque( true ) also has no effect.  Both of
these routines worked

correctly in Java 1.3.1 but now fail.


REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run code at bottom in Java 1.3.1
2. Run code at bottom in Java 1.4
3.

EXPECTED VERSUS ACTUAL BEHAVIOR :
I expect that the JTabbedPane should be transparent when I perform

setOpaque( false ).

I think this has something to do with
JTabbedPane
now providing background across it's contentPanes, but
the ability to
make them transparent should be supported.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
// Have a ball!
import java.awt.*;
import javax.swing.*;

public class Main {
  public

static void main( String argv[] ) {
    JFrame frame = new JFrame( "Background frame" );

    
JPanel
panel = new JPanel( new BorderLayout());
    panel.setBackground( Color.yellow );
    

panel.setPreferredSize( new Dimension( 200, 200 ) );

    JButton opaqueButton = new
JButton(
"opaque button" );
    opaqueButton.setBackground( Color.white );
    

opaqueButton.setOpaque( true );

    JButton transparentButton = new JButton(
"transparent
button" );
    transparentButton.setBackground( Color.white );
    

transparentButton.setOpaque( false );

    JTabbedPane transparentTabbedPane = new

JTabbedPane();
    transparentTabbedPane.setPreferredSize( new Dimension( 100, 100 ) );
    

transparentTabbedPane.setBackground( Color.green );
    

transparentTabbedPane.setOpaque( false );

    JTabbedPane opaqueTabbedPane = new

JTabbedPane();
    opaqueTabbedPane.setPreferredSize( new Dimension( 100, 100 ) );
    

opaqueTabbedPane.setBackground( Color.green );
    opaqueTabbedPane.setOpaque( true

);

    panel.add( opaqueButton, "North" );
    panel.add( transparentButton, "South" );
    

panel.add( transparentTabbedPane, "East" );
    panel.add( opaqueTabbedPane, "West" );
    

frame.getContentPane().add( "Center", panel );
    frame.pack();
    frame.show();
  
}
}

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

CUSTOMER WORKAROUND :
No obvious workarounds

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

(Review ID: 145189) 
======================================================================

Comments
EVALUATION Note: These new properties are only honored if the the JTabbedPane is non-opaque itself.
22-08-2006

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b06
14-06-2004

EVALUATION These methods affect the area behind the tabs of the tabbed pane, not the content area. By modifying the test case to add a tab you will see this. There are a number of bugs regarding this issue already. I've added their ids to this bug. ###@###.### 2002-05-28 Name: omR10226 Date: 03/03/2003 After the fix the default behaviour of a transparent JTabbedPane(opaque = false) is following: the area behind tabs is transparent, the tabs area is opaque, the content area is opaque(look at the bug 4261116). But if we need any area can be transparent. For example such behaviour is necessary for the bug 4685800. Two new resources were added to BasicLook&Feel: "TabbedPane.tabsOpaque" and "TabbedPane.contentOpaque". It's default values are equal to True. To make the tabs area transparent you should replace value of the "TabbedPane.tabsOpaque" by False ( UIManager.put("TabbedPane.tabsOpaque", Boolean.FALSE) ). To make the content area transparent you should replace value of the "TabbedPane.contentOpaque" by False ( UIManager.put("TabbedPane.contentOpaque", Boolean.FALSE) ). ###@###.### ======================================================================
11-06-2004