JavaFX Tab Text and Size Issues - css

Currently having a couple issues with JavaFX and CSS stylesheets. I would like to have the selected tab text to be black, and have the non selected tabs to be white. I was able to achieve the background color of the active tab being a darker blue than the rest, but still have an awkward area around the tabs.
Here is the app when it first opens:
First Open
Here is the app when I click on a tab:
First Click
On the second image the text gets completely lost in the background color. If you could help me get rid of the space around the tabs themselves as well that would be awesome too!
Here is my CSS file:
/*main.css*/
/*set individual tab properties*/
.tab {
-fx-background-color: #1c6fb8;
-fx-font: 16px "Helvetica Neue" ;
-fx-background-radius: 0;
}
.tab-label {
-fx-text-fill: #fff;
}
.tab:focused .tab-label {
-fx-text-fill: #000;
}
.tab-header-background {
-fx-background-color: #1c6fb8;
}
.tab-pane {
-fx-tab-min-width:120px;
-fx-tab-max-width:120px;
-fx-tab-min-height:50px;
-fx-tab-max-height:50px;
-fx-background-color: #15558c;
}
.tab:selected {
-fx-text-fill: #000;
-fx-background-color: #15558c;
}
.tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
-fx-background-color: #15558c;
}
Thanks in advance!

Key code:
.tab-pane .tab:selected
{
-fx-background-color: #15558c;
}
.tab:selected .tab-label
{
-fx-text-fill: #000;
-fx-background-color: #15558c;
}
Full code:
.tab {
-fx-background-color: #1c6fb8;
-fx-font: 16px "Helvetica Neue" ;
-fx-background-radius: 0;
}
.tab-label {
-fx-text-fill: #fff;
}
.tab:focused .tab-label {
-fx-text-fill: #000;
}
.tab-header-background {
-fx-background-color: #1c6fb8;
}
.tab-pane {
-fx-tab-min-width:120px;
-fx-tab-max-width:120px;
-fx-tab-min-height:50px;
-fx-tab-max-height:50px;
-fx-background-color: #15558c;
}
/*.tab:selected {
-fx-text-fill: #000;
-fx-background-color: #15558c;
}*/
.tab-pane .tab:selected
{
-fx-background-color: #15558c;
}
.tab:selected .tab-label {
-fx-text-fill: #000;
-fx-background-color: #15558c;
}
First Open:
First Click:

Related

How to remove border on JavaFX TabPane?

I have this css styling for tabpane javafx:
.tab {
-fx-background-color: #002f6c;
}
.tab-pane>*.tab-header-area>*.tab-header-background
{
-fx-background-color: -fx-outer-border, -fx-text-box-border, #002f6c;
}
.tab:selected {
-fx-background-color: #0041a0;
}
.tab-label {
-fx-text-fill: #ffffff;
}
.tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator
{
-fx-border-radius: 0px;
-fx-border-width: 0px 0px 0px 0px;
-fx-border-color: #4d1a4dff;
}
But i still can't rid of this white border near my tabs:
Can somebody help me with it?
The white border effect is because of the background color insets applied on .tab-header-background. Modifiying the code below should do the trick.
.tab-pane>*.tab-header-area>*.tab-header-background {
-fx-background-color: #002f6c;
-fx-background-insets:0;
}

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:

css-files are partly appplied when building a windows.exe from a a javafx project using j4launch as a wrapper

I have a Javafx project developed in eclipse with some css-files for table and chart backgrounds. In eclipse everything works fine, but when I use j4launch to built a windows .exe the css- files is not applied to the tables and (what seems very strange to me) only one of two line charts shows the wanted background. Both line charts refer to the the same css-file bau are situated in different tabs. I am using jre1.8.0_211. Can someone help me? It would be great. Thank you Marcus
I checked in scenebuilder that the refered css-files are all in the project. I cleaned and rebuilt the project and tried j4launch again, but the results are the same.
This is the first line in the project controller.fxml (sa there seam to be issues with the UTF-8:
<?xml version="1.0" encoding="UTF-8"?>
This is the css code attached to the barchart:
.chart {
-fx-padding: 10px;
}
.chart-content {
-fx-padding: 30px;
}
.chart-title {
-fx-text-fill: #ffffff;
-fx-font-size: 1.6em;
}
.axis-label {
-fx-text-fill: white ;
}
.chart-legend {
-fx-background-color: #8c9cca;
-fx-padding: 20px;
}
.chart-legend-item-symbol{
-fx-background-radius: 0;
}
.chart-legend-item{
-fx-text-fill: #ffffff
}
.chart-plot-background {
-fx-background-color: transparent;
}
.chart-vertical-grid-lines {
-fx-stroke: #3278fa;
}
.chart-horizontal-grid-lines {
-fx-stroke: #8c9cca;
}
.chart-alternative-row-fill {
-fx-fill: transparent;
-fx-stroke: transparent;
-fx-stroke-width: 0;
}
and this is the css for the tables:
.table-view{
-fx-background-color: transparent;
}
.table-view{
-fx-border-color: red;
}
.table-view:focused{
-fx-background-color: transparent;
}
/* Spaltenköpfe
Struktur column-header-background -> column-header */
.table-view .column-header-background{
-fx-background-color: linear-gradient(#131313 0%, #424141 100%);
}
.table-view .column-header-background .label{
-fx-background-color: transparent;
-fx-text-fill: white;
}
.table-view .column-header {
-fx-text-fill: bisque ;
-fx-background-color: transparent;
}
.table-view .table-cell{
-fx-text-fill: White;
-fx-font-size: 14px;
}
.table-row-cell{
-fx-background-color: -fx-table-cell-border-color, #616161;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.0em; /* 0 */
}
.table-row-cell:odd{
-fx-background-color: -fx-table-cell-border-color, #424242;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.0em; /* 0 */
}
.table-row-cell:selected {
-fx-background-color: #CBDAFF;
-fx-background-insets: 0;
-fx-background-radius: 1;
-fx-border-color: #b3c7dc;
}
.table-view:focused .table-row-cell:selected .table-cell {
-fx-text-fill: black;
}
.table-view > .virtual-flow > .scroll-bar:vertical,
.table-view > .virtual-flow > .scroll-bar:vertical > .track,
.table-view > .virtual-flow > .scroll-bar:vertical > .track-background,
.table-view > .virtual-flow > .scroll-bar:horizontal,
.table-view > .virtual-flow > .scroll-bar:horizontal > .track,
.table-view > .virtual-flow > .scroll-bar:horizontal > .track-background
{
-fx-background-color: transparent;
}
.table-view > .virtual-flow > .scroll-bar > .increment-button,
.table-view > .virtual-flow > .scroll-bar > .decrement-button {
-fx-opacity: 0;
}
No error messages. The windows programm is running bit the the stylesheets ara just partly applied (see above).

css: How to change row color of a table after its been selected and clicked away

I have .css when the row is selected which is fine.
However when I click off the row it changes the row color grey with a black font, is there any way to edit this css?
.table-view {
-fx-base: transparent;
-fx-control-inner-background: transparent;
-fx-background-color: #507CA6;
-fx-padding: 5;
}
.table-view .column-header-background {
-fx-background-color: transparent;
}
.table-view .column-header, .table-view .filler {
-fx-size: 35;
-fx-border-width: 0 0 1 0;
-fx-background-color: transparent;
-fx-border-color: #B4D9FD;
-fx-border-insets: 0 10 1 0;
}
.table-view .column-header .label {
-fx-font-size: 14pt;
-fx-font-family: "Segoe UI Light";
-fx-text-fill: white;
-fx-alignment: center-left;
-fx-opacity: 1;
}
.table-view:focused .table-row-cell:filled:focused:selected {
-fx-background-color: #273D51;
}
Any help would be appreciated.
Try this:
/* When control is selected but not focused */
.table-row-cell:filled:selected,
.table-row-cell:filled > .table-cell:selected {
-fx-background: red;
}
first make selected class than use this script, i always use this $("tr").click(function(){
$(this).addClass("selected").siblings().removeClass("selected");
});​

Resources