When we bind the tabMinWidthProperty of a TabPane to the widthProperty of the Scene divided by the number of Tab, the expected behavior is that the tab's width grows up as the scene's width.
Thats works as expected.
But, if you click on the last tab, all the tabs scroll to left, even if the last tab is completly visible. This is done in the "headersRegion" of the TabHeaderArea when the method "layoutChildren" is invoked.
It would be nice to allow to disable this behavior.
There is a question about that on stackoverflow: http://stackoverflow.com/questions/23955114/javafx-cant-remove-extra-space-at-the-right-of-tabpane
There is an example:
public class MainTabPaneApp extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage){
stage.setHeight(600);
stage.setWidth(800);
TabPane tabPane = new TabPane();
tabPane.getTabs().addAll(createTab("Tab1"), createTab("Tab2"), createTab("Tab3"));
Scene scene = new Scene(tabPane);
stage.setScene(scene);
stage.show();
scene.getStylesheets().add("tabs.css");
tabPane.tabMinWidthProperty().bind(scene.widthProperty().divide(Bindings.size(tabPane.getTabs())));
}
private static Tab createTab(String text){
Tab t = new Tab(text);
t.setClosable(false);
return t;
}
}
And the tabs.css:
*{
-fx-padding: 0;
}
.tab-pane .tab {
-fx-border-radius: 0;
-fx-border-width: 0;
-fx-padding: 0;
-fx-background-insets: 0;
}
.tab-header-area{
-fx-border-width: 0;
-fx-padding: 0;
}
.control-buttons-tab {
visibility: hidden;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-padding: 0;
}
.control-buttons-tab>.container {
visibility: hidden;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-padding: 0;
}
.container>.arrow {
visibility: hidden;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-padding: 0;
}
Thats works as expected.
But, if you click on the last tab, all the tabs scroll to left, even if the last tab is completly visible. This is done in the "headersRegion" of the TabHeaderArea when the method "layoutChildren" is invoked.
It would be nice to allow to disable this behavior.
There is a question about that on stackoverflow: http://stackoverflow.com/questions/23955114/javafx-cant-remove-extra-space-at-the-right-of-tabpane
There is an example:
public class MainTabPaneApp extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage){
stage.setHeight(600);
stage.setWidth(800);
TabPane tabPane = new TabPane();
tabPane.getTabs().addAll(createTab("Tab1"), createTab("Tab2"), createTab("Tab3"));
Scene scene = new Scene(tabPane);
stage.setScene(scene);
stage.show();
scene.getStylesheets().add("tabs.css");
tabPane.tabMinWidthProperty().bind(scene.widthProperty().divide(Bindings.size(tabPane.getTabs())));
}
private static Tab createTab(String text){
Tab t = new Tab(text);
t.setClosable(false);
return t;
}
}
And the tabs.css:
*{
-fx-padding: 0;
}
.tab-pane .tab {
-fx-border-radius: 0;
-fx-border-width: 0;
-fx-padding: 0;
-fx-background-insets: 0;
}
.tab-header-area{
-fx-border-width: 0;
-fx-padding: 0;
}
.control-buttons-tab {
visibility: hidden;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-padding: 0;
}
.control-buttons-tab>.container {
visibility: hidden;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-padding: 0;
}
.container>.arrow {
visibility: hidden;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-padding: 0;
}