Styling JFoenix Tabpane - javafx

I am using JFoneix Library for creating a tabpane in javafx. Everything works fine however i am unable to remove the extended line connecting the tabs. How can i achieve that?
Below Css has been used to design the tabpane
#testDatesTab .tab-selected-line {
-fx-background-color: #0059A9;
}
#testDatesTab .headers-region {
-fx-background-color: #F5F6F8;
}
#testDatesTab .tab-header-background {
-fx-background-color: white;
}
#testDatesTab .control-buttons-tab{
-fx-background-color:white;
}
#testDatesTab .control-buttons-tab .tab-down-button{
-fx-background-color: #0059A9 ;
}
#testDatesTab *.tab-header-area {
-fx-padding: 0 0 0 0;
}

Using those style lines you should not have problems, maybe if you have something else in your css it is what is causing that problem, look I just made an example.
Add your full css.

Related

How to get the Round Corners in JFXTextField or TextField using CSS in JavaFX

I am building an application using JavaFX and I have a form with JFXTextFields and JFXComboBoxes. I need to round them like round corners as the following picture.
Like this:
I have tried the following CSS code:
.jfx-text-field {
-fx-border-radius: 20px;
-fx-background-radius: 20 20 20 20;
-fx-border-color: #609;
}
But the result is this:
So how to round the text fields and combo boxes using CSS in JavaFX?
The .css-files used by JFoenix can be found at JFoenix-master\jfoenix\src\main\resources\com\jfoenix\assets\css\controls. The .css-file belonging to JFXTextField is jfx-text-field.css and the .css-file belonging to JFXComboBox is jfx-combo-box.css.
The styles defined in these files have to be adapted in a user-defined .css-file according to the requirements, e.g.:
.jfx-text-field,
.jfx-combo-box {
-fx-border-radius: 20px;
-fx-border-color: #CCCCCC;
}
.jfx-text-field {
-fx-padding: 0.333333em 1em 0.333333em 1em;
}
.jfx-combo-box {
-fx-padding: 0em 1em 0em 1em;
}
.jfx-text-field > .input-line,
.jfx-combo-box > .input-line {
-fx-background-color: transparent;
-fx-pref-height: 0px;
-fx-translate-y: 0px;
}
.jfx-text-field > .input-focused-line,
.jfx-combo-box > .input-focused-line {
-fx-background-color: transparent;
-fx-pref-height: 0px;
}
In the first block the border-radius and border-color are defined and in the following two blocks the padding. In the last two blocks the input line is disabled, which is still visible in the originally posted screenshot above. The result is:
The posted style is only an example and has to be adapted / optimized according to your requirements.

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;
}

-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.

JavaFX: Hide ComBox arrow

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;
}

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