Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javafx combobox styling

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 down to be shown above the combobox (insetad of display below the combobox) .

Is it possible ? Can we do this with css ?

Thanks for any help.

like image 458
Dil Avatar asked Oct 13 '13 09:10

Dil


1 Answers

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;
}
like image 100
Anshul Parashar Avatar answered Oct 14 '22 08:10

Anshul Parashar