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;
}
Related
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.
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?
I tried to implement different coloring of my TreeTableView since there are DummyElements that should be separated visually from the other elements. Since they still are editable and stuff, there also has to be a certain style when they are selected. I tried the follownig:
.tree-table-row-cell:selected .text {
-fx-fill: white ;
}
.tree-table-row-cell .tree-table-cell:selected {
-fx-background-color: grey
}
.tree-table-cell .text {
-fx-fill: black ;
}
.tree-table-cell {
-fx-background-color: gainsboro
}
I dont know why, but the text color changes but the backgroundcolor
doesnt. Why is this?
Okay as always, when I post something here on SO, i find the answer shortly after, but since this is not very intuitive I wanted to share the solution.
.tree-table-row-cell:selected .text {
-fx-fill: white ;
}
.tree-table-row-cell:selected .tree-table-cell {
-fx-background-color: grey
}
.tree-table-cell .text {
-fx-fill: black ;
}
.tree-table-cell {
-fx-background-color: gainsboro
}
You want the to change the fx-background-color property of the tree-table-cell of the tree-table-row-cell:selected pseudo class.
You DONT want to change the fx-background-color property of the tree-table-cell:selected pseudo class since it doest no exist (afaik).
The thing is, that naming of all classes is a bit weird in javaFX...
I have tried the following with no success:
.tree-view {
-fx-skin: "com.sun.javafx.scene.control.skin.TreeViewSkin";
-fx-background-color: green, -fx-control-inner-background;
-fx-background-insets: 0, 1;
}
What I am trying to achieve is to set a blue background for an entire TreeView except the selected one. Setting the background on the selected tree item works fine, but changing for the entire tree view does not have any effect.
You can color the individual TreeCells by using the .tree-cell selector:
.tree-view {
-fx-background-color:lightsteelblue;
}
.tree-cell {
-fx-background-color:lightsteelblue; // Default color
}
.tree-view:focused .tree-cell:filled:selected {
-fx-background-color:indigo; // Focused color
}
.tree-cell:filled:selected{
-fx-background-color:lightcyan; // Unfocused color
}
Produces something like this:
I have a fairly simple JavaFX control that I am trying to stylize with a CSS stylesheet.
I have the background set up fine but I have several Text shapes that are necessary because the control itself can vary in size and I want to scale the text with the control.
I am trying to stylize the text in a CSS with .text{/*CSS Code*/} but it's not working:
.text{
-fx-fill: #818181;
-fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.7) , 6, 0.0 , 0 , 2 );
}
When I open the FXML file in Scene Builder I have to apply it a style-class before I see the effect.
I wouldn't care but I also want to apply effects when hovering or clicking on the text shapes and evidently with a style class accessing the pseudo-class :hover doesn't work, and by extension I will presume no other pseudo-class works either:
.text:hover{
-fx-fill: #818181;
}
This is the rest I have:
root {
display: block
}
.root{
-fx-background-color: linear-gradient(
from 0% 0% to 100% 100%, #b478ff 0%, #9400d3 100%
);
}
I set the root layout (a gridpane) style-class to "root" and that works (i can see the background gradient colors just fine).
I love the idea of CSS but I can never ever seem to get it to work and it drives me nuts. What am I doing wrong here? To text shapes not have accessible CSS pesudo-classes? Or even classes at all? What am I missing from this?
You have set -fx-fill to the same color in text and text:hover.
For me it works, when I use your CSS: the text of a label and button show a hover effect (I changed fx-fill to another value in text:hover).
Example code: http://pastebin.com/GNDwz626
... I have to apply it a style-class before I see the effect.
you have to do that sometimes unless you use the special css classes
I love the idea of CSS ... To text shapes not have accessible CSS pesudo-classes? ...?
what you need to do is read the modena.css
which is in the jfxrt.jar (location jre\lib\ext) search for it in your jre path modena.css is located at
from modena.css here's some information extracted from the css.
/*******************************************************
* *
* Text COMMON *
* *
******************************************************/
.text-input {
/* ... */
}
.text-input:focused {
/* ... */
}
/*******************************************************
* *
* TextArea *
* *
******************************************************/
.text-area {
/* ... */
}
.text-area > .scroll-pane {
/* ... */
}
.text-area > .scroll-pane > .scroll-bar:horizontal {
/* ... */
}
.text-area > .scroll-pane > .scroll-bar:vertical {
-/* ... */
}
.text-area > .scroll-pane > .corner {
/* ... */
}
.text-area .content {
/* ... */
}
.text-area:focused .content {
/* ... */
}
ScenicView
There is a software called scenic view, you can get it from the fx experience website. You may also use that software to find information about control's css classes.
This is because Text is a shape. So its slightly different.
// Put this in your css
/* This sets the fill for the Text Shape */
Text {
-fx-fill: white;
}