When I upgraded by JavaFX app from JavaFX 2 to JavaFX 8, I noticed that ScrollPanes always showed up as gray rectangles, even with a background color set or the background set to be transparent.
I found the solution in this discussion: https://community.oracle.com/thread/3538169
First I needed this:
.scroll-pane > .viewport {
-fx-background-color: transparent;
}
Then I could set the background color to whatever I like. In this case, I'm making all ScrollPane backgrounds transparent:
.scroll-pane {
-fx-background-color: transparent;
}
Came acroos this just now, it's not working with -fx-background-color, but it is with -fx-background
.scroll-pane {
-fx-background: #FFFFFF;
-fx-border-color: #FFFFFF;
}
To alter borders, you would have to use "fx-background-color" .
To modify the viewport's background color, you should modify the "fx-background" attribute.
I used white for both colors :
scrollPane.setStyle("-fx-background: rgb(255,255,255);\n -fx-background-color: rgb(255,255,255)");
In-source approach:
Once it's added to the scene/stage, you can trigger off the width or height property to get access to the viewport styling.
ScrollPane myPane = new ScrollPane();
myPane.widthProperty().addListener((o) -> {
Node vp = logMessagePane.lookup(".viewport");
vp.setStyle("-fx-background-color:#434547;");
});
Related
I want remove the arrows of a JavaFX Spinner.
I read how to remove the arrows of MenuButton in this link using CSS...but can't figure out how to do in my case .
remove arrows from menubutton
Any idea how ..thanks .
If you want to hide the array shapes you could do the same as the post you mentioned. The CSS properties you are looking for are :
.spinner .increment-arrow-button .increment-arrow {
-fx-padding: 0;
}
.spinner .decrement-arrow-button .decrement-arrow {
-fx-padding: 0;
}
If you don't want to alter their size by changing the padding you could set Shape to something non visible or just change it's background color to -fx-background-color: transparent;
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.
I want the treewidget header to look as if it's a label, so, I guess, I have to make it transparent? How do I do it?
I tried treeWidget->setStyleSheet("QTreeWidget::header {background-color: transparent}"); but it doesn't work.
The header is not a subcontrol of an itemview, thus QTreeWidget::header will not work. The header rather is a children widget of the view.
That means you could access the header via stylesheets with QTreeWidget QHeaderView {/*style here*/ }
For the background color of a header view you can check out the official Qt example.
In your case as you are setting the stylesheet directly to the view you can omit the parent so the following will do what you asked for:
treeWidget->setStyleSheet("QHeaderView::section { background-color: transparent; }");
In order to set the headers transparent, you have to add the following to the widget stylesheet:
QAbstractItemView QHeaderView {
show-decoration-selected: 0;
background: transparent;
}
QAbstractItemView::section QHeaderView::section {
show-decoration-selected: 0;
background: transparent;
}
I am attempting to override the default style of certain columns in a tableview in JavaFX. Basically I would like to have editable values present a lightyellow background so that people know that those columns are editable.
However when I set this CSS on the field:
.editableColumn.table-cell {
-fx-background-color:lightyellow;
-fx-alignment:CENTER-RIGHT;
-fx-border-width: .5px;
-fx-border-style: solid;
-fx-border-color:grey;
}
It removed the rest of the formatting, so highlight bars, etc are gone.
What CSS properties do I need to set so that the highlighting works, so that my values don't vanish (here it's white on yellow so you can't see the value).
Thanks!
If you just want to make sure the text color is appropriate for the background you set, try setting -fx-background to the same value as -fx-background-color:
.editableColumn.table-cell {
-fx-background-color:lightyellow;
-fx-background: lightyellow ;
-fx-alignment:CENTER-RIGHT;
-fx-border-width: .5px;
-fx-border-style: solid;
-fx-border-color:grey;
}
If you want the "selected style" to override the "editable style" for cells that are both in your column and are in a selected row, I think you will need to manually revert to the default styles for selected cells. Something like
.table-row-cell:filled:selected .editableColumn.table-cell {
-fx-background-color: null ;
-fx-border-color: transparent -fx-table-cell-border-color transparent transparent;
/* -fx-border-width: null ; (not sure about this one...) */
}
Is it possible to change the grid color element in Kendo UI?
I have changed the color of the text, without a problem:
.k-grid th.k-header,
.k-grid th.k-header .k-link
{
color:white;
}
How to change the color of the arrow?
The arrow is a png so you have to create your own image and then select it as:
#grid .k-icon.k-i-arrow-n {
background-image: url('path to the image');
background-position: 0 0;
}
You might try playing with CSS transformation and see if you can get the color that you want but that uses to be very easy if they were defined as fonts.