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();
}
}
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();
}
}