.popup-view {
-fx-background-color: red; // nothing happens here
}
.popup-view .scroll-pane {
-fx-background-color: green; // nothing happens here
}
.popup-view .viewport {
-fx-background-color: violet; // color is shown
-fx-border-color: violet;
-fx-background-radius: 7; // no affect
-fx-border-radius: 7;
}
if i remove .viewport it just shows a white background without radius.
i want a popup-view with a certain color and radius for
that background - as violet for example. thanks for any help!
If you check your PopupView control with ScenicView, you'll see that its ScrollPane has as style class root-node.
So your css should be something like this:
.popup-view > .root-node {
-fx-background-color: green;
}
.popup-view > .root-node > .viewport {
-fx-background-color: violet;
-fx-border-color: violet;
-fx-background-radius: 7;
-fx-border-radius: 7;
}
Related
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;
}
Every time I drag a column, I get a blue line across the whole column. I know I can remove it by setting -fx-background-insets: 0;, but I can't figure out where to put it. This line appears only when I'm dragging it, if I'm not doing it, everything is fine.
My current CSS is as follows:
.table-view .column-header,
.table-view .filler,
.table-view .column-header-background .show-hide-columns-button {
-fx-background-color: white;
}
.table-view .column-header {
-fx-border-color: grey;
-fx-border-width: 0 1 0 0;
}
.table-view .column-header-background {
-fx-border-color: grey;
-fx-border-width: 0 0 1 0;
}
.table-view .show-hide-column-image {
-fx-background-color: black;
}
.table-view .column-drag-header,
.table-view .column-overlay {
-fx-background-color: green;
}
.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell:filled:selected,
.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell .table-cell:selected {
-fx-background-color: darkgrey;
-fx-table-cell-border-color: grey;
}
.table-cell {
-fx-border-color: grey;
-fx-border-width: 0 1 0 0;
-fx-text-fill: black;
}
.table-row-cell:focused {
-fx-background-insets: 0;
}
.table-row-cell:selected .table-cell {
-fx-text-fill: black;
}
The only thing I see about this "drag-event" in modena.css is this:
/* When a column is being 'dragged' to be placed in a different position, there
is a region that follows along the column header area to indicate where the
column will be dropped. This region can be styled using the .column-drag-header
name. */
.table-view .column-drag-header,
.tree-table-view .column-drag-header {
-fx-background: -fx-accent;
-fx-background-color: -fx-selection-bar;
-fx-border-color: transparent;
-fx-opacity: 0.6;
}
/* Semi-transparent overlay to indicate the column that is currently being moved */
.table-view .column-overlay,
.tree-table-view .column-overlay {
-fx-background-color: darkgray;
-fx-opacity: 0.3;
}
I tried putting it in both places like so:
.table-view .column-drag-header,
.table-view .column-overlay {
-fx-background-insets:0;
}
But it had no effect.
I thought maybe this "region" is the one that has insets and it's because of it that the blue line appears, but I couldn't find where it is or at least what's it called in the CSS.
Edit: changed the question to "changing the color" instead of removing it, since it seems like a better approach. Solution for changing the color was provided by kleopatra in the comments.
.table-view .column-resize-line {
-fx-background-color: red;
}
From Modena.css, the CSS class .column-resize-line can be used for both TableView and TreeTableView:
/* The column-resize-line is shown when the user is attempting to resize a column. */
.table-view .column-resize-line,
.tree-table-view .column-resize-line {
-fx-background: -fx-accent;
-fx-background-color: -fx-background;
-fx-padding: 0.0em 0.0416667em 0.0em 0.0416667em; /* 0 0.571429 0 0.571429 */
}
I'm trying to allow 5 pixels of space between rows on a JavaFX TreeTableView. I figured that changing the margin, padding, or border width on one of the CSS elements would fix it, but either nothing happens or the text in the table cell is moved around.
I see that there might be solutions for TreeViews and TableViews, like the StackOverflow link below, but they don't appear to apply to TreeTableViews.
How to set space between TableRows in JavaFX TableView?
My Current CSS:
.tree-table-view {
-fx-table-cell-border-color: transparent;
-fx-background-color: black;
}
/* TreeTableView */
.tree-table-view .column-header,
.tree-table-view .column-header-background .filler {
-fx-background-color: black;
-fx-border-width: 100;
}
.tree-table-cell{
-fx-text-fill: white;
-fx-wrap-text: true;
}
.tree-table-row-cell .tree-disclosure-node .arrow {
-fx-shape: null;
-fx-background-color: null;
-fx-min-width: 0;
-fx-pref-width: 0;
-fx-max-width: 0;
-fx-min-height: 0;
-fx-pref-height: 0;
-fx-max-height: 0;
}
.tree-table-row-cell:expanded .tree-disclosure-node .arrow {
-fx-shape: null;
-fx-background-color: null;
-fx-max-width: 0;
-fx-max-height: 0;
}
.tree-table-row-cell{
-fx-background-color: black;
-fx-font-size: 12px;
-fx-indent: 0;
-fx-cell-size: 50px;
}
.group-tree-table-row-cell{
-fx-background-color: darkgray;
}
.entry-tree-table-row-cell{
-fx-background-color: darkslategray;
}
.tree-table-row-cell:selected{
-fx-background-color: darkblue;
-fx-table-cell-border-color: transparent;
}
You will want to apply your style to the tree-table-cell style class (Documentation can be found here: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#treetablecell)
Applying a border width of 5 at the bottom of each cell in a column can give you the desired effect without shifting the text. This can be done by adding the following to your style sheet.
.tree-table-cell {
-fx-border-width: 0 0 5 0;
}
This can also be done by setting a custom cell factory for columns of the TreeTableView and providing the cells with the desired settings. See TreeTableColumn#setCellFactory(Callback<TreeTableColumn<S,T>,TreeTableCell<S,T>> valuehttps://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TreeTableColumn.html#setCellFactory-javafx.util.Callback-).
I want to style my context menu but I can't get rid off white area between menu-item and context-menu border, see example.
rendered context menu with css styles
I want that color fils whole area up to context menu border like this
ecpected styling
My css styles
.context-menu {
-fx-background-color: #FFFFFF;
-fx-effect: null;
-fx-border-color: #D6D9DF;
-fx-border-width: 0.5;
-fx-border-radius: 4;
-fx-background-radius: 4;
-fx-background-insets: 0, 1;
}
.menu-item {
-fx-padding: 0;
-fx-pref-height: 28px;
}
.context-menu .separator {
-fx-padding: 0;
}
.menu-item .label {
-fx-font-size: 12px;
-fx-padding: 6 16 8 12;
-fx-text-fill: #2D3845;
}
.menu-item:focused {
-fx-background-color: transparent;
}
.menu-item:hover {
-fx-background-color: #EAECEF;
}
.menu-item:pressed {
-fx-background-color: #D6D9DF;
}
have you tried adding
yourcontextmenuname.getStyleClass().remove("context-menu");
and then change your CSS to refer yourcontextmenuname by ID. If that does not work do the same with menu-item.
I want to have a textfield with three different borders for three cases:
a white border when not hovered or focused
a grey border when hovering
a blue border when focused and typing
I started like this:
#custom-text-field {
-fx-border-width: 2;
-fx-border-color: white;
}
#custom-text-field:hover{
-fx-border-width: 2;
-fx-border-color: #909090;
}
#custom-text-field:focused{
-fx-border-width: 2;
-fx-border-color: #0093EF;
}
The problem is that the border for focusing never shows up. How do it set it correctly?
I use it like this
.custom-text-field {
-fx-background-color:
#FFFFFF,
#FFFFFF;
-fx-background-insets: 0, 2;
-fx-background-radius: 0, 0;
}
.custom-text-field:focused {
-fx-background-color:
#0093EF,
#FFFFFF;
}
.custom-text-field:hover {
-fx-background-color:
#909090,
#FFFFFF;
}
.custom-text-field:focused:hover {
-fx-background-color:
#0093EF,
#FFFFFF;
}