In JavaFx, I have done a TabPane with this appearance:
As you see, there is a blank on the right, at the space reserved to the arrow button in case of too short TabPane. I would like to fill the TabPane width entirely, without the blank.
Here is my code: HelloApplication.java:
package com.example.demo;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
HelloController.java:
package com.example.demo;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import java.net.URL;
import java.util.ResourceBundle;
public class HelloController implements Initializable {
private static final int GAP = 19;
@FXML
private TabPane tabPane = null;
@FXML
private BorderPane borderPane = null;
@Override
public void initialize(URL location, ResourceBundle resources) {
// Permits to change the width of the tabs to fit all the space.
tabPane.tabMinWidthProperty()
.bind(tabPane.widthProperty()
.divide(tabPane.getTabs()
.size())
.subtract(GAP));
}
}
hello-view.css:
.tab-header-area {
-fx-padding: 0 0 0 0;
}
.tab-header-background {
-fx-background-color: transparent;
}
.tab-down-button {
-fx-padding: -7;
}
.tab-down-button .arrow {
-fx-padding: -7;
}
.tab {
-fx-background-color: transparent;
-fx-border-width: 0 0 0 0;
-fx-background-radius: 0;
-fx-background-insets: 0;
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
.tab-label {
-fx-font-size: 13px;
-fx-font-weight: bold;
}
.tab:hover {
-fx-background-color: cyan;
-fx-border-color: black;
-fx-border-width: 0 0 2 0;
}
.tab:pressed {
-fx-background-color: gray;
-fx-border-color: black;
-fx-border-width: 0 0 2 0;
}
.tab:selected {
-fx-background-color: blue;
-fx-border-color: black;
-fx-border-width: 0 0 2 0;
}
hello-view.fxml:
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import java.net.URL?>
<TabPane fx:id="tabPane" side="BOTTOM" tabClosingPolicy="UNAVAILABLE" xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.demo.HelloController">
<tabs>
<Tab fx:id="trackTab" text="Tracks">
<content>
<BorderPane fx:id="borderPane"/>
</content>
</Tab>
<Tab text="Volumes">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" />
</content>
</Tab>
</tabs>
<stylesheets>
<URL value="@hello-view.css" />
</stylesheets>
</TabPane>
In the controller, I use a binding to have the tabPane width and in the CSS, I try to make the arrow space disappear. Also I would like to get RID of the GAP constant. Have you got a solution ?

Potential approaches
Three possible solutions:
Style the existing tabs the way you want using CSS.
Create a new TabPaneSkin and associated CSS.
Implement your own custom layout, controls, and CSS for managing switching panes.
Custom pane switch implementation
Structure
VBox(contentPane, controlPane)
contentPane contains your switchable panes and is set to:
controlPane provides the tab switching buttons:
When a radio button is actioned, the contentPane is replaced by the appropriate pane for the button.
RadioButtons are used rather than ToggleButtons, so that, when a toggle group is assigned to the buttons, only one is selectable at a time.
The radio buttons have their
radio-buttonstyle removed and are styled like toggle buttons (via CSS) so they appear a bit more like a standard button.Example Code
This example inlines the CSS rather than supplying a separate file, it also uses the
fx:rootconstruct. You could have a separate CSS file and not use thefx:rootconstruct if you wish.The fx:root and inline CSS constructs lack some useful tool support. If these features are not used, you get nicer WYSIWYG viewing in scene builder and improved intelligent editing in your IDE.
pom.xml
module-info.java
MixerApp.java
Mixer.java
mixer.fxml