JavaFX更改标题窗格图标的标题

时间:2014-04-18 07:07:28

标签: java javafx javafx-2 javafx-8

我是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");
    }     
}

但这不起作用。我想我的方法不对。有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

尝试此解决方案:How to change header component in TitledPane in JavaFX 具体做法是:

// 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()
);
相关问题