Tom Nott
I had several back-and-forth e-mails with one of the Sun Swing
developers about it and could not convince him it was a bug. Here is
the text of my submission and the workaround description. Hope this
helps...
----------------------------------
description: The JTabbedPane fail to paint correctly if it contains a
JPanel
which is larger than the JTabbedPane itself. There are two
conditions that lead to this problem: (1) A page of the JTabbedPane
contains a component which is oversize, e.g. larger than the JTabbedPane
itself, and (2) the oversized component is NOT on the first tab.
Here is a short program which shows the problem. When run the
frame is shown with nothing inside it (the JTabbedPane does not
draw itself). The correct behaviour can be obtained by changing
either of the code blocks as indicated in the comments to either
(1) make the component smaller than the tab control, or (2) making
the oversized component the first tab.
import com.sun.java.swing.*;
import java.awt.*;
public class TabBug extends com.sun.java.swing.JFrame {
class TestPanel extends JPanel {
public TestPanel() {
super();
setName("TestPanel2");
setLayout(null);
setSize(500, 810); //<=== Tab fails to paint
//setSize(500, 200); //<=== Works correctly
}
}
public TabBug() {
super();
setName("TabTest");
setDefaultCloseOperation(com.sun.java.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(485, 316);
// Create tabbed pane
JTabbedPane tab = new JTabbedPane();
tab.setBounds(20, 20, 250, 250);
// Fails when oversized panel is 2nd tab:
tab.insertTab("Page 1", null, new JPanel(), null, 0);
tab.insertTab("Page 2", null, new TestPanel(), null, 1);
// Works when oversized panel is 1st tab:
//tab.insertTab("Page 2", null, new TestPanel(), null, 0);
//tab.insertTab("Page 1", null, new JPanel(), null, 1);
JRootPane root = getRootPane();
root.setName("JFrameContentPane");
root.setLayout(null);
root.add(tab);
}
public TabBug(String title) {
super(title);
}
public static void main(java.lang.String[] args) {
TabBug b = new TabBug();
b.setVisible(true);
}
}
company: NCFB Insurance
jdcid: %%userid%%
comments: (company - NCFB Insurance , email - mmcm...@ncfbins.com)
cust_email: mmcm...@ncfbins.com
status: Waiting
workaround: Set the size of components to very small (10x10) before
inserting
them into the JTabbedPane. This may not be practical or possible
with some visual design environments where the tab insert code
is generated by an IDE.
OSversion: win_nt_4.0
severity: 3
dateCreated: July 20, 1999 7:59:36 AM
performance: 1
crash: 1
user_type: E
subcategory: classes_swing
bugtype: bug
hardware: x86
security: 1
cust_name: Mark McMillan
category: java
hang: 1
synopsis: JTabbedPane fail to paint with an oversized child on 2nd page
Thanks
Tom
-Mark
Tom