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

Tab graphics are not cloned properly for popup menu

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u65
    • javafx
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_65"
      Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]
      OSX 10.11.1

      A DESCRIPTION OF THE PROBLEM :
      The clone method in TabPaneSkin doesn't perform a correct, deep clone for the popup menu items.
      When using tabs without text but with a label as graphic, the label's graphic is reassigned to the clone instead of being cloned as well.
      The result thereof is that the labels' graphics in the tabs themselves are missing after the tab selection menu was opened.
      Just using the tab's text property is not an option as we add further functionality to the label, e.g. D'n'D which requires a fx node.

      related to JDK-8089146 and JDK-8093128

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a TabPane with an exceeding amount of tabs, so that the menu button is accessible.
      Make use of Labels with ImageViews as the tabs' graphics.
      Open the drop down menu.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The image views remain within the tabs.
      ACTUAL -
      The image views are removed from the tabs' labels and are instead shown within the menu.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.image.ImageView;
      import javafx.scene.image.WritableImage;
      import javafx.stage.Stage;

      public class Test extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
      WritableImage icon = makeIcon();

      TabPane tabPane = new TabPane();
      tabPane.setMaxWidth(400);
      for (int i = 0; i < 20; i++) {
      Tab tab = new Tab();
      Label label = new Label("label " + i);
      label.setGraphic(new ImageView(icon));
      tab.setGraphic(label);
      tabPane.getTabs().add(tab);
      }

      primaryStage.setScene(new Scene(tabPane));
      primaryStage.show();
      }

      private WritableImage makeIcon() {
      WritableImage image = new WritableImage(16, 16);
      int c = 0xff000000;
      for (int x = 0; x < 16; x++) {
      for (int y = 0; y < 16; y++) {
      image.getPixelWriter().setArgb(x, y, c);
      c += 0x00010000;
      }
      }
      return image;
      }
      }

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

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: