[英]JavaFX changing header of titled pane icon
我是JavaFX的新手。 在我的應用程序中,我正在使用標題窗格,我想從左到右替換默認的最小化圖標位置。 問題是我正在為標題窗格使用單獨的FXML文件,它包含在場景中。 我用下面的css內容來實現我的目標。
.titled-pane > .title > .arrow-button .arrow {
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
-fx-padding: 0.25em 0.3125em 0.25em 0.3125em; /* 3 3.75 3 3.75 */
-fx-collapsible: false;
-fx-shape: "";
起初我嘗試使用上面的css刪除圖標。
public class PrjExplorerController implements Initializable {
@FXML
TitledPane titledPanePrjExplorer;
@Override
public void initialize(URL url, ResourceBundle rb) {
titledPanePrjExplorer.getStylesheets().add("StyleSheet.css");
boolean b = titledPanePrjExplorer.getStyleClass().add("titled-pane");
}
}
但這不起作用。 我想我的方法不對。 有人可以幫我嗎?
試試這個解決方案: 如何在JavaFX中更改TitledPane中的標題組件具體來說:
// translate the titledpane arrow and header so that the arrow is displayed to right of the header.
Pane connectivityArrow = (Pane) connectivityPane.lookup(".arrow");
connectivityArrow.translateXProperty().bind(
connectivityPane.widthProperty().subtract(connectivityArrow.widthProperty().multiply(2))
);
Pane connectivityTitle = (Pane) connectivityPane.lookup(".header");
connectivityTitle.translateXProperty().bind(
connectivityArrow.widthProperty().negate()
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.