Javafx combobox styling


Question

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.

1
5
10/20/2013 5:26:15 PM

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;
}
28
2/14/2017 4:58:50 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon