4

Searching in caspian.css I found that I can customize dialog-pane.Alert extends Dialog so I tried some of of these lines of code:

.dialog-pane {
   -fx-background-color: black;
   -fx-padding: 0;
    .....
  }

 .dialog-pane > .expandable-content {
     -fx-padding: 0.666em; /* 8px */
    .....
  }

.dialog-pane > .button-bar > .container {
    -fx-padding: 0.833em; /* 10px */
    .....
  }

.....

but nothing changes.

Question: How can I do that? I mean I want to customize the background, the buttons, the header and everything other.

Cœur
  • 37,241
  • 25
  • 195
  • 267
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93

1 Answers1

17

Take a look here how to add stylesheet or|and styleclass to DialogPane,so you can add your costume css file.

Example(picture + css code):

enter image description here

 .dialog-pane{
  -fx-border-color:black;
  -fx-border-width:2.0px;
 }

/**Costumization of The Bar where the buttons are located**/
.dialog-pane > .button-bar > .container {
  -fx-background-color:black;
}

.dialog-pane > .content.label {
   -fx-padding: 0.5em 0.5em 0.5em 0.5em;
   -fx-background-color: yellow;
   -fx-text-fill:black;
   -fx-font-size:15.0px;
}

/**Costumization of DialogPane Header**/
.dialog-pane:header .header-panel {
  -fx-background-color: black;
}

.dialog-pane:header .header-panel .label{
  -fx-background-color: yellow;
  -fx-background-radius:10px;
  -fx-text-fill:black;
  -fx-font-size:15.0px;
}


/**Costumization of Buttons**/
.dialog-pane .button{
   -fx-background-color:black;
   -fx-text-fill:white;
   -fx-wrap-text: true;
   -fx-effect: dropshadow( three-pass-box, yellow, 10.0, 0.0, 0.0, 0.0);
   -fx-cursor:hand;
 }

.dialog-pane .button:hover{     
  -fx-background-color:white;
  -fx-text-fill:black;
  -fx-font-weight:bold; 
 }
Community
  • 1
  • 1
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93