-
Bug
-
Resolution: Delivered
-
P4
-
6
-
x86
-
solaris_10
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 ----------
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 ----------
- relates to
-
JDK-4690946 REGRESSION: JTabbedPane.setBackground() and setOpaque() have no effect
- Resolved
-
JDK-8226990 GTK & Nimbus LAF: Tabbed pane's background color is not expected one when change the opaque checkbox.
- Resolved