Javafx combobox styling

前端 未结 1 1377
北海茫月
北海茫月 2020-12-28 23:25

I need a combobox in javaFX whose popup behavior can be controlled, like upon clicking the combobox, instead of default behavior where it shows a drop down, i want the drop

相关标签:
1条回答
  • 2020-12-29 00:13

    I hope this will work for you. Make some changes according your need

    .combo-box .list-cell 
    {
        -fx-background: white;
        -fx-background-color: transparent;
        -fx-text-fill: -fx-text-base-color;
        -fx-padding: 3 0 2 7;
        -fx-cell-size: 1.66667em; 
    }
    
    .combo-box-popup .list-view 
    {
        -fx-background-color: white, white;
        -fx-background-insets: 0, 1;
        -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 8, 0.0 , 0 , 0 );
    }    
    
    .combo-box-popup .list-view .list-cell 
    {
        -fx-padding: 4 0 4 5;
    
        /* No alternate highlighting */
        -fx-background-color: white;
    }
    
    .combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover 
    {
        -fx-background: -fx-accent;
        -fx-background-color: -fx-selection-bar;
        -fx-text-fill: -fx-selection-bar-text;
    }
    
    .combo-box-popup .list-view .list-cell:filled:hover 
    {
        -fx-background-color: white;
        -fx-text-fill: -fx-text-inner-color;
    }
    
    .combo-box-base  
    {
        -fx-skin: "com.sun.javafx.scene.control.skin.ComboBoxBaseSkin";
        -fx-background-color: white, white, white, white;
        -fx-background-radius: 5, 5, 4, 3;
        -fx-background-insets: 0 0 -1 0, 0, 1, 2;
        -fx-padding: 0;
    }
    
    .combo-box-base:hover
    {
        -fx-color: -fx-hover-base;
    }
    
    .combo-box-base:showing 
    {
        -fx-color: -fx-pressed-base;
    }
    
    .combo-box-base:focused {
        -fx-background-color: -fx-focus-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
        -fx-background-radius: 6.4, 4, 5, 3;
        -fx-background-insets: -1.4, 0, 1, 2;
    }
    
    .combo-box-base:disabled {
        -fx-opacity: .4;
    }
    
    0 讨论(0)
提交回复
热议问题