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-).
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 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 need an advice with the styling of date picker module in Java FX with an assistance of CSS classes.
It is specifically the popup window in which I used also the scenic view to look up the CSS code. But doesn't work in the popup window. I need a help how to style popup in the calendar view.
(using intelijIdea)
This is my code and the attached picture.
.date-picker .combo-box {
-fx-background-insets:0px ;
-fx-border-width: 0px;
}
.date-picker .text-field{
-fx-background-radius:0px ;
-fx-border-color: transparent;
}
.date-picker .arrow-button{
-fx-background-radius:0px ;
-fx-background-color: #232323;
}
.date-picker .arrow-button .arrow{
-fx-background-radius:0px ;
-fx-background-color: #1783CC;
}
.date-picker .arrow-button:hover .arrow{
-fx-background-radius:0px ;
-fx-background-color: #40a9ef;
}
.date-picker .button {
-fx-background-color: transparent;
-fx-border-color:transparent;
-fx-pref-height: 35px;
-fx-pref-width: 35px;
}
.date-picker .button:hover {
-fx-border-color:transparent;
-fx-pref-height: 35px;
-fx-pref-width: 35px;
}
.date-picker .button .arrow:pressed {
-fx-border-color:transparent;
-fx-pref-height: 35px;
-fx-pref-width: 35px;
}
.date-picker .cell {
-fx-background-color: #232323;
-fx-pref-width:20px ;
-fx-pref-height:25px ;
}
.date-picker .cell:hover {
-fx-background-color: #1783CC;
-fx-pref-width:20px ;
-fx-pref-height:25px ;
}
.date-picker .cell:focused {
-fx-background-color:#11659e;
-fx-pref-width:20px ;
-fx-pref-height:25px ;
}
.date-picker-popup {
-fx-border-color: #1783CC;
-fx-background-color: black;
}
Most style classes of the DatePicker popup can be found in the DatePickerContent.java or in one of the JavaFX's theme stylesheet.
For instance, if you're using the modena theme then you will find the these styleclasses in modena.css (from line 2934)
A quick workaround when using ScenicView would be to prevent the popup from being closed:
datePicker.setOnHidden(new EventHandler<Event>() {
#Override
public void handle(Event event) {
datePicker.show();
}
});
I am using BreadcrumbBar from ControlsFX which works fine. The only problem i have is styling it to look like the image below. When using scenic view i saw that this component only has three classes .bread-crumb-bar, .button, .first. I tried adding border image like so, but did not appear.
/*
* ControlFX bread crumb
*
*/
.bread-crumb-bar {
}
.bread-crumb-bar .button {
-fx-padding: 0 3 0 3;
-fx-border-color: null;
-fx-border-insets: 0;
-fx-border-image-source: url("../images/icon/crumb-focused.png");
-fx-border-image-slice: 1 10 1 10 fill;
-fx-border-image-width: 1 10 1 10;
-fx-border-image-repeat: stretch;
}
.bread-crumb-bar .button.first {
}
How can i style controlsfx breadcrumb to look like breadcrumb in the image
That's how i have solved it very similar. For the slash you need the image.
You need to fiddle around with padding and set your font-family appropriately. Didnt find a selector for the last/selected crumb.
bread-crumb-bar {
-fx-background-color: transparent;
}
.bread-crumb-bar .button {
-fx-padding: 8 12 8 20;
-fx-border-color: null;
-fx-border-insets: 0;
-fx-content-display: left;
-fx-background-position: left center;
-fx-background-repeat: no-repeat;
-fx-background-image: url("../img/slash.png");
-fx-background-color: transparent;
-fx-border-color: transparent;
-fx-shape: null;
}
.bread-crumb-bar .first {
-fx-background-color: transparent ;
-fx-border-color: transparent;
-fx-font-size: 1.11em;
-fx-text-fill: #000;
-fx-background-image: null;
-fx-shape: null;
-fx-padding: 8 12 8 0;
}
.crumb {
-fx-text-fill: #000;
}
.crumb:hover,
.crumb:selected,
.crumb:focused
{
-fx-background-color: rgba(0,0,0,0.1);
-fx-border-color: null;
-fx-font-size: 1.11em;
-fx-text-fill: rgba(0,0,0,0.5);
}