-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
windows_2000
FULL PRODUCT VERSION :
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b44)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b44, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
I'm creating a Swing-based small application. There is one JFrame, containing a JMenuBar, a JToolBar, and a CardLayout within the JFrame (BorderLayout.CENTER). There are two cards, one is an empty JComponent with a dull grey background, the other contains a JTabbedPane. The dull background card is shown when no file is loaded, flipping to the JTabbedPane when a file is loaded.
Before the file is loaded, the JTabbedPane contains no tabs, but the component IS added to the layout (it gets reused, but all tabs are added on load and removed on file close). The exact tabs added will depend on the file contents, so can't be created before loading the file.
This works fine with Java SE 5 (update 4), but doesn't work under Java SE 6-ea-b44 (more details later in this report). Briefly, Java SE 6 throws an exception when laying out components when one of the components is a JTabbedPane with no tabs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run my test case. Run it under Java SE 5, then Java SE 6 (b44). My test case includes one line that's "commented out", which adds a dummy tab. Recompile with this tab, and the problem goes away.
It seems to occur with the default look and feel, the Windows look and feel, and I suspect with all others too...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It works as in Java SE 5.
ACTUAL -
Under Java SE 6 (b44), a stacktrace is generated during layout. See the error message (next field in bug report, below).
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneScrollLayout.layoutContainer(BasicTabbedPaneUI.java:3003)
at java.awt.Container.layout(Container.java:1397)
at java.awt.Container.doLayout(Container.java:1386)
at java.awt.Container.validateTree(Container.java:1469)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validate(Container.java:1444)
at java.awt.Window.show(Window.java:592)
at java.awt.Component.show(Component.java:1406)
at java.awt.Component.setVisible(Component.java:1359)
at java.awt.Window.setVisible(Window.java:573)
at test.TabbedPaneTest.main(TabbedPaneTest.java:20)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javax.swing.*;
public class TabbedPaneTest
{
public static void main(String[] args)
{
JFrame frame = new JFrame("Tabbed pane test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP,JTabbedPane.SCROLL_TAB_LAYOUT);
// pane.addTab("One",new JLabel("First tab"));
frame.add(pane);
frame.setSize(480,320);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add a dummy tab, remembering to remove it when adding "real" tabs at a later time, and ensuring it's added back again when removing the "real" tabs when closing the file being edited (the application doesn't close, it can load a different file thereafter).
Release Regression From : mustang
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b44)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b44, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
I'm creating a Swing-based small application. There is one JFrame, containing a JMenuBar, a JToolBar, and a CardLayout within the JFrame (BorderLayout.CENTER). There are two cards, one is an empty JComponent with a dull grey background, the other contains a JTabbedPane. The dull background card is shown when no file is loaded, flipping to the JTabbedPane when a file is loaded.
Before the file is loaded, the JTabbedPane contains no tabs, but the component IS added to the layout (it gets reused, but all tabs are added on load and removed on file close). The exact tabs added will depend on the file contents, so can't be created before loading the file.
This works fine with Java SE 5 (update 4), but doesn't work under Java SE 6-ea-b44 (more details later in this report). Briefly, Java SE 6 throws an exception when laying out components when one of the components is a JTabbedPane with no tabs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run my test case. Run it under Java SE 5, then Java SE 6 (b44). My test case includes one line that's "commented out", which adds a dummy tab. Recompile with this tab, and the problem goes away.
It seems to occur with the default look and feel, the Windows look and feel, and I suspect with all others too...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It works as in Java SE 5.
ACTUAL -
Under Java SE 6 (b44), a stacktrace is generated during layout. See the error message (next field in bug report, below).
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneScrollLayout.layoutContainer(BasicTabbedPaneUI.java:3003)
at java.awt.Container.layout(Container.java:1397)
at java.awt.Container.doLayout(Container.java:1386)
at java.awt.Container.validateTree(Container.java:1469)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validateTree(Container.java:1476)
at java.awt.Container.validate(Container.java:1444)
at java.awt.Window.show(Window.java:592)
at java.awt.Component.show(Component.java:1406)
at java.awt.Component.setVisible(Component.java:1359)
at java.awt.Window.setVisible(Window.java:573)
at test.TabbedPaneTest.main(TabbedPaneTest.java:20)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javax.swing.*;
public class TabbedPaneTest
{
public static void main(String[] args)
{
JFrame frame = new JFrame("Tabbed pane test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP,JTabbedPane.SCROLL_TAB_LAYOUT);
// pane.addTab("One",new JLabel("First tab"));
frame.add(pane);
frame.setSize(480,320);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add a dummy tab, remembering to remove it when adding "real" tabs at a later time, and ensuring it's added back again when removing the "real" tabs when closing the file being edited (the application doesn't close, it can load a different file thereafter).
Release Regression From : mustang
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
- duplicates
-
JDK-6270998 REGRESSION: Exception in BasicTabbedPaneUI with Mustang build 34 and above.
- Resolved