JDK-8161122 : [macosx] Aqua Look and Feel: JTabbedPane.setIndexAt(index,title) updates tabs incorrectly if replacing an HTML-formatted title.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u92
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • CPU: x86
  • Submitted: 2016-07-08
  • Updated: 2016-07-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8-poolUnresolved
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
$ java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
$ uname -a
Darwin scrappy.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64


A DESCRIPTION OF THE PROBLEM :
Only with the Mac OS X Aqua look and feel (apple.laf.AquaLookAndFeel), when JTabbedPane setTitleAt(index,title) replaces an HTML-formatted title, all previously existing titles are incorrectly pushed over.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program on a Mac with the Aqua look and feel:

java -Dswing.defaultlaf=apple.laf.AquaLookAndFeel bug6670274

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The attached program (copied from: http://bugs.java.com/view_bug.do?bug_id=6670274) creates three tabs initially:

0 = "one"
1 = "<html><i>Two</i></html>"
2 = "three"

It then does:

pane.setTitleAt(0, "ONE");

The expected result is:

0 = "ONE"
1 = "<html><i>Two</i></html>" (HTML-formatted)
2 = "three"


ACTUAL -
Run the attached program on a Mac:

java -Dswing.defaultlaf=apple.laf.AquaLookAndFeel bug6670274

Instead of the expected result, you see this:

0 = "ONE"
1 =  "<html><i>Two</i></html>" (as raw text, not HTML-formatted)
2 =  "<html><i>Two</i></html>" (HTML-formatted)

The title "three" has been pushed off the end.

Other look and feels generate correct results:

java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel bug6670274

java -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel bug6670274

This bug has apparently already been fixed in Java 9; apple.laf.AquaLookAndFeel  generates correct results in a Java 9 EA release.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class bug6670274 {

    public static void main(String[] args) throws Exception
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                bug6670274.createGui();
            }
        });
    }

    private static void createGui()
    {
        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JTabbedPane pane = new JTabbedPane();
        pane.add("one", new JPanel());
        pane.add("<html><i>Two</i></html>", new JPanel());
        pane.add("three", new JPanel());
        pane.setTitleAt(0, "ONE");
        frame.add(pane);
        frame.setSize(200, 200);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

---------- END SOURCE ----------


Comments
Tested this for 8u92, 8u102ea, 9ea on Mac OS and could confirm the issue as reported by the bug submitter. Steps to reproduce: ********************** Run the attached test case(bug6670274.java) with JDK. > javac bug6670274.java > java -Dswing.defaultlaf=apple.laf.AquaLookAndFeel bug6670274 Test result : ************** OS : OS X El Capitan [version 10.11.5] JDK: 7u40 b43 : Fail 7u80 b15 : Fail 8u25 b18 : Fail 8u92 b14 : Fail 8u102ea b14 : Fail 9ea+122 : Pass ======================================================== This issue is reproducible with JDK 7 and 8 family on mac OS. So, moving this issue to JDK for dev engineer's review.
11-07-2016