JDK-6462396 : TabbedPane.contentOpaque doesn't work properly and is inconsistent across LAFs
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Delivered
  • OS: solaris_10
  • CPU: x86
  • Submitted: 2006-08-22
  • Updated: 2024-05-22
  • Resolved: 2024-05-22
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.
JDK 23
23Resolved
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0-rc-b95)

A DESCRIPTION OF THE PROBLEM :
During evaluation of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4685800
I came upone bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4690946
which says this about 'contentOpaque':
"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) )."

This leaves the reader believing that the way to make the contentArea opaque is to have the property set to False.  From observing the behavior of code that mixes setOpaque(true/false) and true/false for the property it appears that this is incorrect.  The property appears to
only cause an effect when the TabbedPane is not opaque.  What makes this worse is that it also only appear to have an effect with Basic derived LAFS like metal and motif.  Synth appears to ignore the property entirely.  Maybe this report is a duplicate of 4685800, and if so maybe the evaluation for 4690946 should be ammended so that it doesn't give the reader the wrong impression.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this test and see how things do not gel.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
That when the property is set to false that the contentArea will not be opaque.  When it is set to true that the contentArea will be opaque.
ACTUAL -
Dependant upon LAF, content area may not be opaque.   It also may be opaque when you are not expecting it.

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class JTabbedPane_contentOpaque implements Runnable{


    public void run(){
        UIManager.put("TabbedPane.contentOpaque", Boolean.TRUE);
        JTabbedPane jtp = createJTP();
        jtp.setOpaque(true);
        jtp.setBorder(new TitledBorder("contentOpaque = true and opaque"));
        JTabbedPane jtp2 = createJTP();
        jtp2.setOpaque(false);
        jtp2.setBorder(new TitledBorder("contentOpaque = true and not opaque"));
        UIManager.put("TabbedPane.contentOpaque", Boolean.FALSE);
        JTabbedPane jtp3 = createJTP();
        jtp3.setOpaque(true);
        jtp3.setBorder(new TitledBorder("TabbedPane.contentOpaque = false, and opaque"));
        JTabbedPane jtp4 = createJTP();
        jtp4.setOpaque(false);
        jtp4.setBorder(new TitledBorder("TabbedPane.contentOpaque = false, and not opaque"));
        JPanel jp = new JPanel(new GridLayout(2,2));
        jp.setBackground(Color.green);
        jp.add(jtp); jp.add(jtp2); jp.add(jtp3); jp.add(jtp4);
        JFrame jf = new JFrame();
        jf.add(jp);
        jf.pack();
        jf.setSize(700,700);
        jf.setVisible(true);
    }

    JTabbedPane createJTP(){
	JTabbedPane jtp = new JTabbedPane();
        for(int i = 0; i < 5; i ++){
            JPanel jp = new JPanel();
            jp.setOpaque(false);
            jp.add(new JButton(String.valueOf(i)));
            jtp.addTab(String.valueOf(i), jp);
        }
        return jtp;
    }

    public static void main(String ... args){
            try{
                int i = Integer.parseInt(args[0]);
                if(i == 0) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                else if(i == 1)UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

            }catch(Exception x){}
	SwingUtilities.invokeLater(new JTabbedPane_contentOpaque());
    }


}
---------- END SOURCE ----------

Comments
[~abhiscxk] in such case closed as a dup of JDK-8226990
20-05-2024

EVALUATION I've updated 4690946 with the following note: "Note: These new properties are only honored if the the JTabbedPane is non-opaque itself." As far as the difference between Synth/GTK and Basic, it should be fixed. All Look and Feels shipped with Swing should be consistent and respect these two properties if possible.
22-08-2006