JavaFX: Hide ComBox arrow - javafx

I am trying to hide the ComboBox arrow using the method in here, but for some reason I get this:

Try this:
.combo-box, .arrow, .arrow-button{
-fx-background-color: transparent;
}
to get rid of all other colours appearing (focused: border-color/border-glow and unfocused: shadow) add .text-field
.combo-box, .arrow, .arrow-button, .text-field{
-fx-background-color: transparent;
}
be aware that every text-field/arrow/arrow-button will be affected. To get around this, you need to add your css-style-sheet to the node itself
your-combo-box-node.getStylesheets().add(Main.class.getResource("styles.css").toExternalForm());
If you need more flexibility with the styling of the individual parts of the node itself, split up the css-code-line
.combo-box{ -fx- ... }
.arrow{ -fx- ... }
.arrow-button{ -fx- ... }
.text-field{ -fx- ... }

This is really old post but just an update if anybody need it. If you want to style just one combo box you can do it in two other ways. First to define id of the combo in Css
#idOfTheComboBox> .arrow-button > .arrow {
-fx-background-color: transparent;
}
#idOfTheComboBox> .arrow-button {
-fx-background-color: transparent;
}
or with class
.your-class > .arrow-button > .arrow {
-fx-background-color: transparent;
}
.your-class > .arrow-button {
-fx-background-color: transparent;
}

Related

How to create a flat progress bar in JavaFX?

I am using Java FXML.
The progress bars look like this:
JavaFX Progress Bar
How do I remove the grey border around, but maintain the background.
To look like this:
Desired Progress Bar
Thanks!
You need to add a stylesheet and do this:
.progress-bar > .bar, .progress-bar > .track {
-fx-background-insets: 0;
}
You can do your own research from CSS Reference and Modena Theme CSS if you have similar problems in the future.
For my case, flat progress bar working with following style sheet
.progress-bar > .bar {
-fx-padding:0;
-fx-background-radius:0;
-fx-background-insets: 0;
-fx-background-color: black;
}
.progress-bar > .track {
-fx-background-color: lightgray, white;
-fx-background-radius:0;
-fx-background-insets: 0, 1;
}

JFoenix: JFXTabPane tab-selected-line color and width

I work with the JFoenix-Library and have a problem.
How can I change the width of the tab-selected-line. I tried the following code but it doesnt work:
.jfx-tab-pane .tab-selected-line {
-fx-border-color: green;
-fx-stroke-width: 3px;
}
I can set the color of the selected line but the width wont work. So i tested it on another way.
I set the border-width and the border-color of the tab like this:
.jfx-tab-pane .tab:selected {
-fx-border-width: 0 0 4 0;
-fx-border-color: green;
}
But after that, I cant set the selected-line color. It takes the default color.
enter image description here
This works for me.
.jfx-tab-pane .tab-selected-line {
-fx-background-color: white;
}
For change stroke color must use -fx-stroke
You can use this:
.jfx-tab-pane .tab-selected-line {
-fx-stroke: green;
-fx-stroke-width: 5pt;
}

JavaFX how to style the button part of a checkbox?

I am trying to do some css styling in a stylesheet for a JavaFX scene.
It is going to be loaded upon opening the scene, and targets all the "basic" elements of a scene.
My problem is that i can't seem to find the right combination of code, to change the background color, of the button in a standard JavaFX checkbox.
This is where i am now:
.check-box:selected{
-fx-background-color: #00FF00;
}
I have tried some variants of the above, like
.check-box .button{
-fx-fill: #00FF00;
-fx-background-color: #00FF00;
}
and others, but without success.
So in general, how do i access a button in a checkbox?
Thank you in advance :-)
The parts of the CheckBox to apply the -fx-background-color to are .box and .box > .mark in case you want to change the mark color:
.check-box:selected > .box {
/* background color for selected checkbox */
-fx-background-color: lime;
}
.check-box > .box {
/* background color of unselected checkbox */
-fx-background-color: red;
}
.check-box:selected > .box > .mark,
.check-box:indeterminate > .box > .mark {
/* modify mark color */
-fx-background-color: blue;
}

-fx-background-color for confirmation dialog box's OK button doesn't work if it's a variable

a.css:
.dialog-pane .button {
-fx-background-color: -fx-base; -fx-text-fill: white;
}
Code:
Alert confirmationDialog = new Alert(AlertType.CONFIRMATION);
confirmationDialog.getDialogPane().getStylesheets().add("a.css");
When I open the confirmation dialog, the Cancel button is styled correctly, but the OK button is not. However, if I change -fx-background-color to an actual color, like:
.dialog-pane .button {
-fx-background-color: red; -fx-text-fill: white;
}
Both buttons will be styled correctly. I've been googling for a while and I'm stumped. Any ideas why this is happening?
The default stylesheet handles the default button by changing the definition of -fx-base:
.button:default {
-fx-base: -fx-default-button;
}
So setting the background to -fx-base won't remove the default blue color.
It's not clear quite what you want to achieve, but you are probably needing something like
.dialog-pane .button {
-fx-background-color: -fx-base;
-fx-text-fill: white;
}
.dialog-pane .button:default {
-fx-background-color: -fx-default-button;
}
and then wherever you are changing -fx-base you should also change -fx-default-button.
I see my confusion. I was working on an existing stylesheet that was trying to use -fx-base like a variable even though it's the name of an existing attribute.

Different font color for not selected tab's tab-label

I try to style Java FX 8 TabPane component via CSS. Currently I'm struggling with different font color for selected and not selected tab-label. At the end, I want selected tab to have white font color, and not selected tab to have black font color. Unfortunately, I don't know how to refer to not selected or only to selected tab-label. I tried .tab-label:selected but it didn't work. I also tried something as .tab:selected > .tab-label but again, didn't work.
Below is CSS code I wrote so far and preview of the TabPane.
#tabPane {
-fx-background-color: #FFFFFF;
}
#tabPane .tab-header-background {
-fx-background-color: #FFFFFF;
}
#tabPane .tab {
-fx-background-color: #d0d0d0;
-fx-background-radius: 0;
-fx-padding: 5 10 10 10;
}
#tabPane .tab:selected {
-fx-background-color: #202020;
-fx-focus-color: transparent;
}
#tabPane .tab-label {
-fx-text-fill: #FFFFFF;
-fx-font-size: 18px;
}
PS Mentioned TabPane was modified only by above CSS code. There are no other modifications. Thus, no additional code.
I think
#tabPane .tab:selected .tab-label {
-fx-text-fill: black ;
}
should work. It may be important to have that after your #tab-pane .tab-label rule.

Resources