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

Changing the managedProperty of a Tab graphic does not have any effect

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u20
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:

      Description

      If I set a Node, which is managed==false, as the graphic of a Tab and later setManaged(true), it doesn't show up as the graphic of the Tab.

      Run the code and click the button, which sets managed(true) and visible(true) on the graphic.
      Nonetheless nothing happens.

      It only works, if the graphic is managed==true, when it is added, but then the total place for the invisible graphic is reserved, which I am trying to avoid.

      Tested with 8u40-ea.



      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.stage.Stage;

      public class TestApp2 extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(final Stage stage) throws Exception {

              Button graphic = new Button("XXX");
              graphic.setVisible(false);
              graphic.setManaged(false);

              TabPane tabPane = new TabPane();
              Tab tab = new Tab("Test Tab");
              tab.setGraphic(graphic);

              Button button = new Button("Click me, to show graphic");
              button.setOnAction(event -> {
                  graphic.setVisible(true);
                  graphic.setManaged(true);
                  // Expected behavior here: The button shows up as the Tab graphic.
              });
              tab.setContent(button);
              tabPane.getTabs().add(tab);

              Scene scene = new Scene(tabPane);
              stage.setScene(scene);
              stage.show();
          }
      }

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            cschudtjfx Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Imported: