Code: Select all
public class NewMain1 extends Application {
@Override
public void start(Stage primaryStage) {
Application.setUserAgentStylesheet(new CupertinoDark().getUserAgentStylesheet());
TabPane tabPane = new TabPane();
tabPane.getStyleClass().addAll("mytab-pane", TabPane.STYLE_CLASS_FLOATING);
Tab tab1 = new Tab("Short Title");
var button = new Button("Test");
button.setOnAction(e -> tab1.setText("Looooooooooooooooooooooong title"));
var tabContent = new VBox(button);
tab1.setContent(tabContent);
tabPane.getTabs().add(tab1);
Scene scene = new Scene(tabPane, 400, 150);
scene.getStylesheets().add(getClass().getResource("test.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
< /code>
und CSS: < /p>
.mytab-pane > .tab-header-area > .headers-region > .tab {
-fx-min-width: -1;
}
, wie Sie sehen, nur Teil des Titels wird. Gleichzeitig in Modena wird der Titel vollständig angezeigt: