2
當創建帶有定義的最小標籤寬度的標籤頁時,JavaFX將使每個標籤的標籤居中。左對齊JavaFX固定寬度標籤頁中的標籤標籤
有沒有辦法左對齊標籤?我已經試過這樣:
package prv.rli.codetest;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
public class TabPaneFixedWidthLeftAligned extends Application {
public TabPaneFixedWidthLeftAligned() {
}
@Override
public void start(Stage primaryStage) throws Exception {
TabPane pane = new TabPane();
pane.setTabMinWidth(150);
pane.getTabs().addAll(new Tab("Bilbo"), new Tab("Baggins"));
pane.getStylesheets().add("file:///home/rli/devel/repository/source/java/project/apps/CodeTest/src/main/java/prv/rli/codetest/test.css");
Scene scene = new Scene(pane, 640, 480);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
這個CSS
在一起:
.tab-container {
-fx-background-color: red;
-fx-alignment: center-left;
}
.tab-label {
-fx-background-color: blue;
-fx-alignment: center-left;
-fx-text-alignment: left;
}
而背景色。(表示我是在正確的軌道上),我無法影響的文本對齊方式標籤。