Make a dark mode with JavaFx

后端 未结 4 1025
自闭症患者
自闭症患者 2021-02-06 11:35

I was wondering if there is an easy way to make a dark mode using JavaFx and CSS. I have a MenuBar with a CheckMenuItem called \'Dark mode\' and when I click it I want the scene

4条回答
  •  情歌与酒
    2021-02-06 11:39

    Here's mine.

    (Update) The previous one was too opaque.

    .root { 
        -fx-accent: #1e74c6;
        -fx-focus-color: -fx-accent;
        -fx-base: #373e43;
        -fx-control-inner-background: derive(-fx-base, 35%);
        -fx-control-inner-background-alt: -fx-control-inner-background ;
    }
    
    .label{
        -fx-text-fill: lightgray;
    }
    
    .text-field {
        -fx-prompt-text-fill: gray;
    }
    
    .titulo{
        -fx-font-weight: bold;
        -fx-font-size: 18px;
    }
    
    .button{
        -fx-focus-traversable: false;
    }
    
    .button:hover{
        -fx-text-fill: white;
    }
    
    .separator *.line { 
        -fx-background-color: #3C3C3C;
        -fx-border-style: solid;
        -fx-border-width: 1px;
    }
    
    .scroll-bar{
        -fx-background-color: derive(-fx-base,45%)
    }
    
    .button:default {
        -fx-base: -fx-accent ;
    } 
    
    .table-view{
        /*-fx-background-color: derive(-fx-base, 10%);*/
        -fx-selection-bar-non-focused: derive(-fx-base, 50%);
    }
    
    .table-view .column-header .label{
        -fx-alignment: CENTER_LEFT;
        -fx-font-weight: none;
    }
    
    .list-cell:even,
    .list-cell:odd,
    .table-row-cell:even,
    .table-row-cell:odd{    
        -fx-control-inner-background: derive(-fx-base, 15%);
    }
    
    .list-cell:empty,
    .table-row-cell:empty {
        -fx-background-color: transparent;
    }
    
    .list-cell,
    .table-row-cell{
        -fx-border-color: transparent;
        -fx-table-cell-border-color:transparent;
    }
    

提交回复
热议问题