Changing the JavaFX Control Panel Header Title

I am new to JavaFX. In my application, I am using the Titled pane, and I want to replace the location of the default minimization icon from left to right. The fact is that I use a separate FXML file for the title bar, and it is included in the scene. I used the content below css to achieve my goal.

.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: "";

First I tried to remove the icon using the above 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");
    }     
}

But that does not work. I think I'm using the wrong approach. Can someone help me with this?

+4
source share
1 answer

Try this solution: How to change the title component in TitledPane in JavaFX In particular:

// 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()
);
0

Source: https://habr.com/ru/post/1537055/


All Articles