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

Making a Tab closeable has no effect until you mouseover the Tab.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Labels:

      Description

      This is probably only a rare use case and not very important, but still...

      If you make a Tab closeable and it wasn't closeable before, the UI doesn't get updated (the "X") until you mouseover the tab or trigger an layout update somehow.

      Run the example, select Tab2, click the button, which makes it closeable. Noting happens, until you mouseover the tab header.


      import javafx.application.Application;
      import javafx.beans.property.BooleanProperty;
      import javafx.beans.property.SimpleBooleanProperty;
      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.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TestApp4 extends Application {

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

          public void start(final Stage stage) throws Exception {

              final VBox root = new VBox();

              TabPane tabPane = new TabPane();

              Tab tab1 = new Tab("Test1");

              tabPane.getTabs().add(tab1);

              final BooleanProperty isCloseable = new SimpleBooleanProperty(false);

              tab1.closableProperty().bind(isCloseable);

              Button button = new Button("make Tab1 closeable");
              button.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      isCloseable.set(true);
                  }
              });

              root.getChildren().addAll(tabPane, button);
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();
          }
      }

        Attachments

          Activity

            People

            Assignee:
            kwwong Kinsley Wong
            Reporter:
            cschudtjfx Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: