JDK-4198538 : Non-opaque component on JTabbedPane bad
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1998-12-18
  • Updated: 2000-03-16
  • Resolved: 2000-03-16
Related Reports
Duplicate :  
Description

Name: clC74495			Date: 12/18/98


I think this should be viewed as a bug...
but I'm not 100% sure...

If I have a JTabbedPane with a JLabel as the component on the tab,
and the JLabel has its opaque property as false, the contents of the
JLabel will overlay on top of the old contents from the previously
selected tab.

See sample program in workaround.

If you uncomment the setOpaque lines, everything is fine. However,
if you don't and change tabs, prior tab contents are not cleared.
(Review ID: 48195)
======================================================================

Comments
WORK AROUND Name: clC74495 Date: 12/18/98 import javax.swing.*; import java.awt.*; public class Test1 extends JFrame { public Test1() { JTabbedPane pane = new JTabbedPane(); JLabel l1 = new JLabel("One", SwingConstants.LEFT); JLabel l2 = new JLabel("Two", SwingConstants.CENTER); JLabel l3 = new JLabel("Three", SwingConstants.RIGHT); // l1.setOpaque(true); // l2.setOpaque(true); // l3.setOpaque(true); pane.addTab("One", l1); pane.addTab("Two", l2); pane.addTab("Three", l3); setContentPane(pane); setSize(300, 300); } public static void main(String[] args) { new Test1().show(); } } ====================================================================== 2 workarounds: 1) make the JTabbedPane opaque: pane.setOpaque(true); 2) put the JTabbedPane inside the default contentPane instead of making IT the content-pane: getContentPane().add(pane, BorderLayout.CENTER);
11-06-2004

EVALUATION The bug is actually caused by the fact that Swing's painting implementation doesn't deal with a non-opaque component set as the content-pane. The contents of the buffer will never be properly cleared in this case. (The default opacity of a JTabbedPane is false). This is really a duplicate of 4155103. amy.fowler@Eng 2000-03-15
15-03-2000