Change toolbar background color in javafx - javafx

I have created my application toolbar with application.e4xmi.
And thereafter I tweaked my .css as below
/* JavaFX CSS - Main CSS-File */
.root {
-fx-base: rgb(222, 234, 247);
-fx-background: rgb(222, 234, 247);
}
.tab {
-fx-background-color: linear-gradient(to top, -fx-base, derive(-fx-base,30%));
}
.menu-bar {
-fx-background-color: linear-gradient(to bottom, -fx-base, derive(-fx-base,30%));
}
.tool-bar > .container{
}
.tool-bar:vertical {
}
.tool-bar:horizontal {
-fx-background: #ececec;
-fx-base: #ececec;
}
.tree-view{
-fx-focus-color: #f21a3f;
}
/*.table-view {
-fx-control-inner-background: rgb(222, 234, 247);
-fx-table-cell-border-color:derive(-fx-base,+10%);
-fx-table-header-border-color:derive(-fx-base,+20%);
} */
.split-pane:horizontal > * > .split-pane-divider {
-fx-control-inner-background : rgb(255, 255, 255);
-fx-border-color: transparent -fx-base transparent -fx-base;
-fx-background-color: transparent, derive(-fx-base,20%);
-fx-background-insets: 0, 0 1 0 1;
}
.my-gridpane {
-fx-background-color: radial-gradient(radius 100%, derive(-fx-base,20%), derive(-fx-base,-20%));
}
.separator-label {
-fx-text-fill: orange;
}
Now I am trying to change background color of high-lighted area of toolbar in my eclipse RCP application.
Any suggestion would be appreciated.

You can use a define a CSS and add this CSS to your product:
.MTrimBar {
background-color: #000000;
}

Related

Howto get the correct CSS item for DatePicker (JavaFX11)

how do I change the CSS of month label and year label? they are grayish and I want to change to white. I cant find the CSS for these two items.
Current CSS code of this datepicker:
/**
* https://gist.github.com/maxd/63691840fc372f22f470
*/
.calendar-grid {
-fx-background-color: rgb(20, 156, 255);
}
.combo-box-popup > .list-view > .placeholder > .label {
-fx-text-fill: white;
}
.calendar-header {
-fx-background-color: #1d1d1d;
-fx-base: #1d1d1d;
-fx-text-fill: white;
}
.date-picker-popup {
-fx-text-fill: white;
-fx-background-color:
linear-gradient(to bottom,
derive(-fx-color,-17%),
derive(-fx-color,-30%)
),
-fx-control-inner-background;
-fx-background-insets: 0, 1;
-fx-background-radius: 0;
-fx-alignment: CENTER; /* VBox */
-fx-spacing: 0; /* VBox */
-fx-padding: 0.083333em; /* 1 1 1 1 */
-fx-effect: dropshadow( gaussian , rgba(0,0,0,0.2) , 12, 0.0 , 0 , 8 );
}
.date-picker > .text-field {
-fx-text-fill: white;
}
.date-picker-popup > .month-year-pane {
-fx-background-color: #1d1d1d;
-fx-text-fill: white;
}
Change the style for the .month-year-pane to
.date-picker-popup > .month-year-pane {
-fx-base: #1d1d1d ;
-fx-mark-highlight-color: -fx-light-text-color ;
}
By default, -fx-background-color is set to fx-background, which in turn depends on -fx-base. The default text fill for controls whose text is rendered over a background of -fx-background is automatically chosen depending on the intensity of the background; in this case it will be set to -fx-light-text-color (which defaults to white).
The arrows are rendered in -fx-mark-highlight-color, so setting this to -fx-light-text-color ensures the arrows are the same color as the text. (Probably better is to mimic the ladder for -fx-text-fill.)
A lot of your CSS seems to have no effect. With the changes above, this seems equivalent:
.calendar-grid {
-fx-background-color: rgb(20, 156, 255);
}
.date-picker > .text-field {
-fx-text-fill: white;
}
.date-picker-popup > .month-year-pane {
-fx-base: #1d1d1d ;
-fx-mark-highlight-color: -fx-light-text-color ;
}
Note that the rule
.date-picker > .text-field {
-fx-text-fill: white;
}
makes the text in the text field (i.e. the selected date) invisible; I don't know if this is the desired effect.
Looking through the source code I found the labels use the spinner-label style class so I think you can just do:
.date-picker .spinner-label {
-fx-text-fill: white;
}

How to remove borders in TableView header in JavaFX

I'm using TableView in many places in my javaFX application. I'm working on a dark mode theme and want to style this table. Now i can't manage to remove the borders in the header row. Also, the text color in the table rows remains black although the rest of text appears white (because of a dark color for -fx-base in root css class) in my application. The table looks like this:
The css:
.root {
-fx-base:#292929;
}
.table-view {
-fx-background-color: transparent;
-fx-border-color: all-dialog-border-color;
-fx-border-width: 1;
-fx-table-header-border-color: transparent;
-fx-table-cell-border-color: transparent;
-fx-text-fill: white;
}
.table-view .column-header-background
{
-fx-background-color: -fx-base;
}
.table-row-cell
{
-fx-background-insets: 0, 0 0 1 0;
-fx-background-color: transparent;
-fx-text-fill: white;
}
.table-column {
-fx-alignment: CENTER;
}
.table-view:focused .table-row-cell:focused {
-fx-table-cell-border-color: transparent;
}
I want to remove the borders between the columns in the header and make the text in table rows appear white. How do i achieve this?
just play with this Css, it should give you all the customization you want
.table-view{
-fx-background-color: white;
-fx-font-size: 20px;
-fx-border-color: derive(black, -60%);
}
.table-view:focused{
-fx-background-color: derive(-fx-primary, 20%);
}
.table-row-cell {
-fx-cell-size: 40px;
-fx-border-style:solid inside;
-fx-border-width:2;
}
.table-view .column-header-background{
-fx-background-color: white;
}
.table-view .column-header-background .label{
-fx-background-color: transparent;
-fx-text-fill: black;
-fx-text-weight:strong;
-fx-border-style:solid inside;
-fx-border-width:2;
-fx-border-radius:20;
-fx-padding:7;
-fx-font-size:18;
}
.table-view .column-header {
-fx-background-color: transparent;
}
.table-view .table-cell{
-fx-text-fill: black;
-fx-font-size:15;
-fx-alignment:center;
-fx-border-style:solid inside;
-fx-border-width:1;
}
.table-row-cell:focused, .table-cell:focused{
-fx-text-fill: red;
}
.table-row-cell{
-fx-background-color: -fx-primary;
-fx-border-color: black;
-fx-table-cell-border-color: transparent;
}
.table-row-cell:empty{
-fx-background-color:white;
-fx-border-color: transparent;
-fx-table-cell-border-color: transparent;
}
.table-column{
-fx-alignment: CENTER;
}
.table-row-cell:even{
-fx-background-color: derive(white, -10%);
}
.table-row-cell:odd{
-fx-background-color: white;
}
.table-row-cell:even:hover{
-fx-background-color:pink;
}
.table-row-cell:odd:hover{
-fx-background-color: skyblue;
}
.table-row-cell:even:empty{
-fx-background-color: white;
}
.table-row-cell:odd:empty{
-fx-background-color: white;
}
.table-row-cell:selected {
-fx-background-color: black;
-fx-text-fill: white;
-fx-background-insets: 0;
}
.table-row-cell:selected .table-cell{
-fx-text-fill: white;
}
After going through the TableView css suggested by Tule Simon, I realized some css classes were missing.
To remove the border from table header, use:
.table-view .column-header
{
-fx-border-style: none;
}
To make the text in the cells appear white:
.table-cell
{
-fx-text-fill: white;
}
Result:

scss: how to dynamically create variables from array

I have this
$colors:
"dark" #3E3E3E,
"darker" #3E3E3E,
"light" #ECECF0,
"green" #00A87B,
"yellow" #FFBB3B,
"red" #FF4633,
"white" #FFFFFF,
"black" #000000,
"blue" #436FB6
;
#each $color in $colors{
// .btn-color
.btn-#{nth($color, 1)}{
background: nth($color, 2);
color: #fff;
}
// .color / color
.#{nth($color, 1)}, #{nth($color, 1)}{
color: nth($color, 2) !important;
a{
color: nth($color, 2);
}
}
// .color-bg
.#{nth($color, 1)}-bg {
background: nth($color, 2);
}
}
It dynamically creates various classes. How can I extend this to make variables for each $colors example — i need to use $dark to reach the dark value from $colors
If you are going to automate color variations I recommend you to take a look into the native color functions provided by Sass (http://sass-lang.com/documentation/Sass/Script/Functions.html).
Here is an example based on a color map (IMO simpler to work with compared to list):
$colors:(
green : #00A87B,
yellow : #FFBB3B,
red : #FF4633,
blue : #436FB6,
white : #FFFFFF,
black : #000000
);
#each $name, $color in $colors {
.color {
&-#{$name}{
background-color: $color;
// create variations (if not black or white)
#if $color != white and $color != black {
&.extra-light { background-color: mix($color, white, 25%); }
&.light { background-color: mix($color, white, 50%); }
&.semi-light { background-color: mix($color, white, 75%); }
&.extra-dark { background-color: mix($color, black, 25%); }
&.dark { background-color: mix($color, black, 50%); }
&.semi-dark { background-color: mix($color, black, 75%); }
}
}
}
}
CSS output
.color-green { background-color: #00A87B;}
.color-green.extra-light { background-color: #bfe9de;}
.color-green.light { background-color: #80d4bd;}
.color-green.semi-light { background-color: #40be9c;}
.color-green.extra-dark { background-color: #002a1f;}
.color-green.dark { background-color: #00543e;}
.color-green.semi-dark { background-color: #007e5c;}
.color-yellow { background-color: #FFBB3B;}
.color-yellow.extra-light { background-color: #ffeece;}
.color-yellow.light { background-color: #ffdd9d;}
.color-yellow.semi-light { background-color: #ffcc6c;}
.color-yellow.extra-dark { background-color: #402f0f;}
.color-yellow.dark { background-color: #805e1e;}
.color-yellow.semi-dark { background-color: #bf8c2c;}
.color-red { background-color: #FF4633;}
.color-red.extra-light { background-color: #ffd1cc;}
.color-red.light { background-color: #ffa399;}
.color-red.semi-light { background-color: #ff7466;}
.color-red.extra-dark { background-color: #40120d;}
.color-red.dark { background-color: #80231a;}
.color-red.semi-dark { background-color: #bf3526;}
.color-blue { background-color: #436FB6;}
.color-blue.extra-light { background-color: #d0dbed;}
.color-blue.light { background-color: #a1b7db;}
.color-blue.semi-light { background-color: #7293c8;}
.color-blue.extra-dark { background-color: #111c2e;}
.color-blue.dark { background-color: #22385b;}
.color-blue.semi-dark { background-color: #325389;}
.color-white { background-color: #FFFFFF;}
.color-black { background-color: #000000;}
Function based approach:
$colors:(
green : #00A87B,
yellow : #FFBB3B,
red : #FF4633,
blue : #436FB6,
white : #FFFFFF,
black : #000000
);
#function get-color($color, $variant: null){
$color: map-get($colors, $color);
#return map-get((
extra-light: mix($color, white, 25%),
light: mix($color, white, 50%),
semi-light: mix($color, white, 75%),
semi-dark: mix($color, black, 75%),
dark: mix($color, black, 50%),
extra-dark: mix($color, black, 25%)
),$variant) or $color;
}
.class { color: get-color(green); }
.class { color: get-color(green, semi-light); }
.class { color: get-color(yellow, dark); }

Text styled with CSS does not appear white

I have got this code:
private void createAndAddCommonInformationSection(){
Text text = new Text("CommonText");
gridPane.add(header);
}
The should appear in white color, so I have a CCS-file as follows:
.root {
-fx-base: rgb(50, 50, 50);
-fx-background: rgb(50, 50, 50);
-fx-control-inner-background: rgb(50, 50, 50);
}
.tab {
-fx-background-color: linear-gradient(to top, -fx-base, derive(-fx-base,30%));
}
.menu-bar {
-fx-background-color: linear-gradient(to bottom, -fx-base, derive(-fx-base,30%));
}
.tool-bar:horizontal {
-fx-background-color:
linear-gradient(to bottom, derive(-fx-base,+50%), derive(-fx-base,-40%), derive(-fx-base,-20%));
}
.button {
-fx-background-color: transparent;
}
.button:hover {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
-fx-color: -fx-hover-base;
}
.table-view {
-fx-table-cell-border-color:derive(-fx-base,+10%);
-fx-table-header-border-color:derive(-fx-base,+20%);
}
.split-pane:horizontal > * > .split-pane-divider {
-fx-border-color: transparent -fx-base transparent -fx-base;
-fx-background-color: transparent, derive(-fx-base,20%);
-fx-background-insets: 0, 0 1 0 1;
}
.my-gridpane {
-fx-background-color: radial-gradient(radius 100%, derive(-fx-base,20%), derive(-fx-base,-20%));
}
.separator-label {
-fx-text-fill: orange;
}
.text{
-fx-text-fill: white;
}
Everythin is working fine with the CSS-file, except the the color of the text in my code snippet does not appear in the expected color.
I have already tried
-fx-fill: white;
and
-fx-fill-text: white;
but nothing helps.
What am I doing wrong?
According to the documentation, Text nodes have no default style class. so you need
text.getStyleClass().add("text");
in order for the text node to match the CSS selector. Then
.text {
-fx-fill: white ;
}
will work.
Typically you would use a Label along with the fx-text-fill property if you want to style it with CSS, though adding a style class manually to a Text node should work.

example of styled javafx chart with CSS code

So I've been working for a while on a JavaFx application (for internal use of my company), which works great, but whenever I'm showing it to my colleagues, i always get the response "the application is great, but why is it so ugly?" , so i wend to look for examples of styled Javafx charts, and except of the Oracle documentation, i really found nothing, for buttons Oracle published a very nice post- here, but nothing similar for JavaFx charts.
I already looked for examples on Google's image gallery, but except for Oracle documentation, there's almost nothing.
Could some one be kind and post a nice CSS code that would end this embarrassment?
I'm attaching my current CSS code, Unfortunately i don't have enough reputation for posting images (snap of the application).
Any suggested Modification of my current CSS will be great just as well.
#appContainer {
-fx-background-color: linear-gradient(to bottom, #464646, #5f5f5f);
-fx-spacing:30;
}
.button {
-fx-background-color:
#000000,
linear-gradient(#7ebcea, #2f4b8f),
linear-gradient(#426ab7, #263e75),
linear-gradient(#395cab, #223768);
-fx-background-insets: 0,1,2,3;
-fx-background-radius: 6;
-fx-padding: 12 30 12 30;
-fx-text-fill: white;
-fx-font-size: 12px;
-fx-spacing:30;
}
.button:hover{
-fx-background-color: linear-gradient(black, white);
}
.combo-box {
-fx-background-color:
#000000,
linear-gradient(#7ebcea, #2f4b8f),
linear-gradient(#426ab7, #263e75),
linear-gradient(#395cab, #223768);
-fx-background-insets: 0,1,2,3;
-fx-background-radius: 3,2,2,2;
-fx-padding: 12 30 12 30;
-fx-text-fill: -fx-text-base-color;
-fx-font-size: 12px;
}
.combo-box:hover{
-fx-background-color: white;
}
#buttonMenuContainer {
-fx-background-color: linear-gradient(to bottom, #737373, #595959);
-fx-padding: 10px;
-fx-spacing:30;
}
.chart-title {
-fx-font-size: 32px;
-fx-font-family: "Arial Black";
-fx-text-fill: #F8F8F8 ;
-fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.7) , 6, 0.0 , 0 , 2 );
}
.chart-alternative-row-fill {
-fx-fill: transparent;
-fx-stroke: transparent;
-fx-stroke-width: 0;
}
.chart-vertical-grid-lines {
-fx-stroke: transparent;
}
.chart-horizontal-grid-lines {
-fx-stroke: transparent;
}
.axis {
-fx-text-fill: #4682b4;
}
.chart {
-fx-padding: 10px;
-fx-background-color:
#000000,
linear-gradient(#7ebcea, #2f4b8f),
linear-gradient(#426ab7, #263e75),
linear-gradient(#395cab, #223768);
-fx-text-fill: white;
}
.chart-plot-background{
-fx-padding:0px;
-fx-font-family: Verdana;
-fx-background-color: linear-gradient(to bottom right, lightsteelblue, white);
}
.chart-content{
-fx-background-color: linear-gradient(to bottom right, lightsteelblue, white);
-fx-padding:30px;
-fx-border-color: linear-gradient(to bottom right, lightsteelblue, white);
-fx-border-width: 5;
-fx-border-insets: -5;
}
.CategoryAxis{
-fx-color:black;
}
.chart-legend{
-fx-background-color:white;
}
.axis {
-fx-font-size: 1.4em;
-fx-tick-label-fill: black;
-fx-font-family: Tahoma;
-fx-tick-length: 20;
-fx-minor-tick-length: 10;
}
.chart-series-line {
-fx-stroke-width: 2px;
}
.default-color0.chart-series-line { -fx-stroke: black; }
.default-color1.chart-series-line { -fx-stroke: white }
.default-color2.chart-series-line { -fx-stroke: blue }
default-color0.chart-line-symbol { -fx-background-color: black, white; }
.default-color1.chart-line-symbol { -fx-background-color: white, white; }
.default-color2.chart-line-symbol { -fx-background-color: blue, white; }
.chart-legend { -fx-background-color: linear-gradient(gray, white);
-fx-font: Arial;
-fx-font-size: 20px;
-fx-text-fill: #F8F8F8 ;
-fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.7) , 6, 0.0 , 0 , 2 );
}
.pane {
-fx-background-color: #8fbc8f;
}
You can lookup the default styling in caspian.css, if you want to know what's possible to style. As to how you should style it, it depends on what you find pretty, so I'd advise you to look up a chart on google that you like and reconstruct it.

Resources