How to change header component in TitledPane in JavaFX

前端 未结 4 1492
栀梦
栀梦 2020-12-03 08:51

I cannot find an answer about this anywhere on the internet.

I have an application that has to have collapsable panels, so the TitledPane and Accordion set-up in Jav

4条回答
  •  一生所求
    2020-12-03 09:23

    In the present day at the end of 2018 nothing of these solutions works with JavaFX of JDK 1.8. So I've working on a simple solution. You can copy this method in and utility class:

    public static boolean hideArrow(TitledPane pane) {
        Node arrowButton = pane.lookup(".arrow-button");
        if (arrowButton == null) {
            return false;
        }
        // I don't know how with this the arrow space disappears...., but it does
        arrowButton.setStyle("-fx-background-color: black;");
        Parent titleRegion = arrowButton.getParent();
        titleRegion.addEventFilter(MouseEvent.ANY, MouseEvent::consume);
        titleRegion.setCursor(Cursor.DEFAULT);
        ((StackPane) titleRegion).getChildren().remove(arrowButton);
        return true;
    }
    

提交回复
热议问题