JDK: 6u10+, JDK7
L&F:
Fails: Nimbus
Passed: others
OS: Solaris/GNOME
When calling pack() on a frame containing tabbed pane under Nimbus, not all the tabs are resized properly.
Please see the attached screenshot that corresponds the following code sample.
It is extracted from JCK testcase.
------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
public class Test_indexAtLocation {
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
final Component components[] = {new Container(), new JButton(), new JCheckBox()};
final String names[] = {"1", "2", "3"};
final JTabbedPane tabbedPane = new JTabbedPane();
for (int j = 0; j < components.length; j++) {
tabbedPane.addTab(names[j], components[j]); // Fill the set
}
final JFrame fr = new JFrame();
fr.getContentPane().add(tabbedPane);
fr.pack();
fr.setVisible(true);
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
Rectangle rr = tabbedPane.getBoundsAt(i);
int index = tabbedPane.indexAtLocation(
rr.x + rr.width / 2, rr.y + rr.height / 2);
if (index != i) {
System.out.println("indexAtLocation returns " + index + " for pane, but " + i + " is expected for[" + i + "] = " + rr + "!");
}
}
System.out.println("OK");
}
});
}
}
------------------------------------------------------------------------------
With -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel
the output will be:
indexAtLocation returns 1 for pane, but 2 is expected for[2] = java.awt.Rectangle[x=25,y=63,width=-7,height=22]!
The following JCK test fails with Nimbus
api/javax_swing/JTabbedPane/index2.html#various[JTabbedPane2302]