Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8161122

[macosx] Aqua Look and Feel: JTabbedPane.setIndexAt(index,title) updates tabs incorrectly if replacing an HTML-formatted title.

    Details

      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 ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dmarkov Dmitry Markov
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: