JavaFX8 ChoiceBox transparent? - java

I want to make a ChoiceBox transparent, so that it looks like a label. Is it possible to hide the arrow on the right and the background? The Popup should be like default.
Which CSS-Classes do I have to use here?
Best regards

Website for this kind of information on css in jfx: CSS Reference Guide
Here is how you can manipulate the nodes inside of a coice box:
.choice-box > .open-button > .arrow{
/* Example: -fx-opacity: 0; */
}
You basically just need to step through all nodes that are inside the choicebox to be able to manipulate the arrow.
If you need any further information i will provide it if i can :)
Hope it helps,
Laurenz
EDIT: that's the full solution:
.choice-box > .open-button > .arrow{
-fx-opacity: 0;
}
.choice-box{
-fx-background-color: transparent;
}
EDIT2: how to use css on nodes with applied id/class?
#mycombobox > .open-button > .arrow{
-fx-opacity: 0;
}
#mycombobox{
-fx-background-color: transparent;
}
Use with CSS class:
.mycombobox > .open-button > .arrow{
-fx-opacity: 0;
}
.mycombobox{
-fx-background-color: transparent;
}

Related

how do you css style a scroll bar in JavaFX?

Is it possible to set the corner of a listview to a specific color or to hide it/make it transparent and if so you how would I do that?
Below are my current attempts to style the listview using css.
.list-view .scroll-bar:vertical {
-fx-background-color:#2c365d;
}
.list-view .increment-button ,.list-view .decrement-button {
-fx-background-color:transparent;
-fx-border-color:transparent;
}
.list-view .scroll-bar:vertical .thumb {
-fx-background-color:#455491;
-fx-background-insets: 5, 5, 5;
-fx-background-radius: 5;
}
.list-view .scroll-bar:horizontal {
-fx-scale-x: 0;
}
You can style the corner of your scroll pane like this:
.scroll-bar > .corner {
-fx-background-color: #2c365d ;
}
I highly recommend Scene Builder and its CSS Analyzer, is great for looking up things like this. Using the CSS Analyzer you can view the "Styleable path" and find the .corner style class, as can be seen in the image below.
Even if you create your GUI in code, you could still use Scene Builder to simply look up things like this and create quick mock-ups.
EDIT:
Though the above answer is fine for Scroll Panes, it's not the exact same for a ListView which is what op wanted - my bad. The ListView have the styleable path:
.list-view .virtual-flow .corner
So this should work to style a corner of a list-view.
.virtual-flow > .corner {
-fx-background-color: #2c365d ;
}
I'm assuming that you will only have one of those ListView and then you could give it an id and only style the corners of your specific ListView.

JavaFX MenuButton only as a Graphic or an Icon with the functionality of a MenuButton

I added a MenuButton and assigned an icon for its graphic. Whenever I hover over the graphic, the color changes from black to blue. The problem is, I don't need to precisely hover over the graphic in order to open the menu. If I were to click on any of the places marked with the red dots the options appear below.
I've looked around and managed to remove as many things as I could find using the following CSS:
#menubutton {
-fx-background-color: transparent;
-fx-background-insets: 0 0 0 0;
-fx-border-color: transparent;
-fx-padding: 0;
}
#menubutton > .arrow-button {
-fx-background-color: transparent;
-fx-padding: 0;
}
#menubutton > .arrow-button > .arrow {
-fx-background-color: transparent;
-fx-padding: 0;
}
But if clicking on those places stills opens the menu options, then it seems like there's still some space between the icon and the border of the button. In this example you can see the space more clearly.
Is there a way to either remove that space or give an icon the functionality of a MenuButton without the button itself?
P.S. The other icons work fine because they're by themselves and not as a graphic in a button.
You need to also turn off the padding to the label within the menu button.
#menubutton > .arrow-button,
#menubutton > .label{
-fx-background-color: transparent;
-fx-padding: 0;
}

JFoenix TabPane tab label colors

I'm working on my javafx project and i'm using JFoenix library. I found everything i need to edit TabPane look by CSS styling, bet one problem still remains - tabs header labels and bottom strip have some kind of blurry/shadow effects, and i can't find, how to fix this. This is my CSS now:
.jfx-tab-pane .tab-header-area .tab-header-background {
-fx-opacity: 0;
}
.tab{
-fx-pref-width: 350;
-fx-pref-height: 50;
}
.jfx-tab-pane .tab-selected-line {
-fx-background-color: -fx-secondary;
}
.jfx-tab-pane .tab .tab-label {
-fx-font-weight: normal;
-fx-text-fill: -fx-primatytext;
-fx-font-size: 16;
}
.jfx-tab-pane .tab-header-area .jfx-rippler{
-jfx-rippler-fill :-fx-secondary;
}
.jfx-tab-pane .tab-selected-line{
-fx-stroke : -fx-secondary;
}
This is how it looks like:
Can you see it? Design of tabpane headers is not flat, like other UI, it have some kind of shadow/blurry effect. Can anyone tell me, where to look to fix this problem?

Menu Style CSS Java

Am hoping someone can advise what is need to be changed to remove the hideous border (?) from this menu (see image).
Have extracted modena from the java jar to see how they do it but to no avail. Sure it's very very simple just drawing a blank at the moment.
The css at the moment is very simple just not sure which element need to be changed / added.
.menu-bar {
-fx-background-color:#237a72;
/*-fx-border-width:2;*/
}
.menu-bar .label {
-fx-text-fill:#ffffff;
}
.menu-bar .label:hover {
-fx-text-fill:yellow;
}
.menu-item {
-fx-background-color:#237a72;
-fx-border-color: #237a72;
}
Many Thanks.
The white border is the background color of the context-menu.
So if you want to get rid of it, you could remove the padding:
.context-menu {
-fx-padding: 0;
}

JavaFX: Hide Slider/Divider of the SplitPane

I have a JavaFX application with a SplitPane. I want do hide the Slider/Divider of SplitPane. How can I do this?
Greetings from Germany (so sorry for my english)
Julian
Its a little different in Java FX8 (modena style):
.split-pane *.split-pane-divider {
-fx-padding: 0 1 0 1;
}
In caspian.css, you will see
/* horizontal the two nodes are placed to the left/right of each other. */
.split-pane:horizontal > * > .split-pane-divider {
-fx-border-color: transparent -fx-box-border transparent #BBBBBB;
-fx-background-color: transparent, -fx-inner-border-horizontal;
-fx-background-insets: 0, 0 1 0 1;
}
/* vertical the two nodes are placed on top of each other. */
.split-pane:vertical > * > .split-pane-divider {
-fx-border-color: #BBBBBB transparent -fx-box-border transparent;
-fx-background-color: transparent, -fx-inner-border;
-fx-background-insets: 0, 1 0 1 0;
}
I am using a vertical one, so I overrided the vertical one in my css as following:
.split-pane:vertical > * > .split-pane-divider {
-fx-border-color: transparent;
-fx-background-color: transparent;
-fx-background-insets: 0;
}
And it works. If you want to hide the grabbers too (e.g. I did not hide it, it seems nice), I think the following rule might do the trick:
.split-pane *.vertical-grabber {
-fx-padding: 0;
-fx-background-color: transparent;
-fx-background-insets: 0;
-fx-shape: " ";
}
I hope it helps.
These other answers still left a thin gray bar so in my CSS I added:
.split-pane-divider {
-fx-background-color: transparent;
}
Another Note:
The divider appears between the children in the Split Pane's list of items. If your split pane only has one item in it, you won't see a divider. If your split pane has 3 items, you will see 2 dividers. If you need to get rid of a divider, you may not need an item in the split pane at all. So just remove the item from the Split Pane's list of items temporarily.
Late, but this is how to do it correctly instead of working around it using CSS:
for (Node node : splitPane.lookupAll(".split-pane-divider")) {
node.setVisible(false);
}
SplitPane.Divider doesn't inherit from Node, therefore it hasn't a disableProperty.
If you need to have a split pane to be resized JUST from the code, you can skin the divider through CSS to be invisible and with a size near 0.
Otherwise use AnchorPane's nested into a VBox

Categories

Resources