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 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");
});
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.
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;
}