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

BasicTabbedPaneUI is creating htmlViews even when html is not used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P5 P5
    • None
    • 6u16
    • client-libs

      java version "1.6.0_16"
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)

      Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
      Yes

      Operating System Configuration Information (be specific):
      Client: Microsoft Windows XP [Version 5.1.2600]

      Bug Description:
      BasicTabbedPaneUI is creating htmlViews even when html is not used

      The JavaDoc for BasicTabbedPaneUI says 'The Views (one per tab title requiring HTML
      rendering) are stored in the htmlViews Vector, which is only allocated after
      the first time we run into an HTML tab.' However the code below demonstrates
      that htmlViews are created even when there are no HTML Tabs.

      Expected: this code to run forever
      Actual: eventually an OutOfMemoryError is thrown (due to the htmlViews which
      should never have been created in the first place getting bigger every call
       to setTitleAt - which is related to bug 6670274)

      import javax.swing.*;

      public class Test {
        public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
              boolean firstTitle = true;
              JTabbedPane tabbedPane = new JTabbedPane();
              tabbedPane.addTab("Title 1", new JLabel("Component"));
              tabbedPane.updateUI();
              while (true) {
                firstTitle = !firstTitle;
                tabbedPane.setTitleAt(0, firstTitle ? "Title 1" : "Title 2");
              }
            }
          });
        }
      }


      }

            Unassigned Unassigned
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: