Javafx/CSS White not Displaying Correctly Against Black Background - css

I have a Javafx interface with white text and a black background, however the white seems REALLY dim, below is the result of my CSS and my code.As you can see there is barely any difference between the white and black even though I explicitly set it to white. Below is the CSS:
#KeyValues{
-fx-background-color:black;
}
#ScienceLabel{
-fx-font-color:white;
}
#GoldLabel{
-fx-font-color:white;
}
Just to note KeyValues is an HBox and the labels are well...labels.

Try using:
-fx-text-fill:white;
Instead of:
-fx-font-color:white;

Related

How to change the standard blue hover and frame effect?

I am using Vaadin version 14.6.3.
Hover and selection effect
In the image above you can see that my app has a greenish color scheme, but the context menu I implemented will always have a blue hover effect and also some blue frame for the active item.
I tried to play around with stlyes.css and shared-styles.js, but I could not manage to find the correct place where to add/overwrite the standard blue "lumo" behavior.
What can I do to customize this behavior to a color of my choice?
#Route(Pages.CUSTOMER_ROUTE)
#StyleSheet("styles.css")
#PageTitle(Pages.CUSTOMER_PAGE_TITLE)
#JsModule("./shared-styles.js")
public class CustomerUI extends VerticalLayout implements RouterLayout, PageConfigurator, RoleSecured, AfterNavigationObserver {...}
Thank you for your help.
You have very likely only set the primary color and not also the 50% and 10% shade colors. See https://vaadin.com/docs/latest/styling/lumo/design-tokens/color/#primary
E.g. try:
html, :host {
--lumo-primary-color: hsl(122, 96%, 47%);
--lumo-primary-color-50pct: hsl(122, 96%, 47%, 0.5);
--lumo-primary-color-10pct: hsl(122, 96%, 47%, 0.1);
}

How do I switch the image files I want to see in a JavaFXML Button?

I am trying to toggle a button between two states. One state is to display an
image of a red circle, the other state being an image of a blue circle. When the user clicks the button it should toggle between the states. I have set
style in my css to accommodate the button:
#button-debit {
-fx-background-image: url("images/redButton.jpg");
}
#button-credit {
-fx-background-image: url("images/blueButton.png");
}
To see if this works I have tried just to transform from red to blue by doing this:
#FXML
private void handledborcrBtn() {
dborcrBtn.setId("button-credit");
}
However the result is not as expected. The red button image stays in place with the blue one underneath it, but the blue image is split up into several parts.
I think I remember a 'repaint' method from javax Swing but there seems to be more complicated with JavaFXML and I'm having trouble getting this to work properly.
Try it with the ToogleBotton
.toggle-button {
-fx-graphic: url('icons.jpg');
}
.toggle-button:selected {
-fx-graphic: url('othericon.png');
}

Keeping the same selection color in a TableView whether it's active or not

I'm using QTableView class in my GUI and I would like the selected row to have the same color whether the TableView is active or inactive.
I tried to set this CSS stylesheet to achieve this:
QTableView:!active {
selection-background-color: palette(Highlight);
selection-color: palette(HighlightedText)
}
On Linux, it works just fine, but on Windows 7, when the TableView loses its focus, the text turns black instead of staying white (the background stays blue, so that part is OK). Am I missing something here ?
You also have to style text color, for example just add:
QTableView:!active {
...
selection-color: white;
}
This works well in python
pal = tbl_list.palette()
pal.setColor(QPalette.Inactive, QPalette.Highlight, pal.color(QPalette.Active, QPalette.Highlight))
tbl_list.setPalette(pal)

CSS Transparency without affecting font color

I have this style in my controller:
vm.backgroundColor = {
'background': '#' + vm.colorHex,
'filter': 'alpha(opacity = 10)',
'-moz-opacity': '0.1', 'opacity': '0.1'
};
How can I use this without affecting the font color? Thanks
By changing the opacity of the whole element, you're by definition fading the whole element.
If you want the background to be semi-transparent, you can achieve this very easily using rgba colours.
The first three numbers represent red, green and blue, and are rated 0-255, and the fourth is the alpha (transparency), which is rated from 0 (transparent) to 1 (no transparency).
The code below would give a transparent red background.
vm.backgroundColor = {
'background' : rgba(255,0,0,0.5)
};

Change the selection color of a QTableWidget

The default is for the selected row to be colored gray if the QTableWidget does not have focus, and orange if it does have focus. I would like to, instead, make the selected row be red whether or not the widget has focus. I tried adding this to the style sheet:
QTableWidget{ selection-background-color: red}
I also tried
QTableWidget:edit-focus{ selection-background-color: red}
and
QTableWidget:focus{ selection-background-color: red}
but none of them seem to turn anything red, it still seems to remain orange if focused and gray if not. What properties do I have to set to make the selected row always the same color, whether or not it has focus?
Thanks,
David
You almost had it. Technically speaking, you're adjusting the selection color of the items within your table widget, so:
QTableWidget::item{ selection-background-color: red}
should do the trick.
Alternatively:
QTableWidget::item{ background-color: blue }
QTableWidget::item:selected{ background-color: red }
background-color will set background color of the items in row and selection-color will set the text color because when the row is selected then if text are present in the row then it might become unreadable due to color so setting proper text color is important.
#d9fffb : light blue
#000000 : black
self.table.setStyleSheet(
"QTableView::item:selected"
"{"
"background-color : #d9fffb;"
"selection-color : #000000;"
"}"
)

Resources