Name: sv35042 Date: 10/18/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 XP
[Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
I have a standard Pentium 4 system with a sound card,
a network card, and a CD-R.
A DESCRIPTION OF THE PROBLEM :
If no tab is present in a JTabbedPane, the background is
always light gray, despite calling setBackground() for
the tabbed pane. When a tab is present, the background above
the tab shows correctly. This same problem existed in 1.3,
but adding the JTabbedPane to a JPanel having the desired
color caused the correct background to display when no tab
was present on the tabbed pane.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Create a JTabbedPane.
2.Create a JPanel with BorderLayout
3.Set the background color of the panel to Color.green.
4.Set the background color of the tabbed pane to
Color.green.
4.Add the tabbed pane to the CENTER portion of the panel.
5.Add the panel to the CENTER of a JFrame.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expect the JTabbedPane backround to be green or expect
the background of the JPanel that contains the tabbed
pane to show green.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame
{
JTabbedPane t;
public Test()
{
Container content = getContentPane();
t = new JTabbedPane();
t.setBackground(Color.green);
JPanel w = new JPanel();
w.setBackground(Color.green);
w.setLayout(new BorderLayout());
w.add(t, BorderLayout.CENTER);
content.add(w, BorderLayout.CENTER);
setSize(300,300);
setTitle("JTabbedPane Test");
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
void x()
{
try
{
Thread.sleep(5000);
}
catch (InterruptedException ie)
{}
t.addTab("Test", new JPanel());
}
public static void main(String[] args) throws Exception
{
Test t = new Test();
t.x();
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Make the JTabbedPane invisible until it has a tab.
(Review ID: 147099)
======================================================================