Eclipse RAP FormToolkit controls ignore CSS style - java

In my Eclipse RAP application I have a theme with declared CSS styles for controls Button, Combo ...
I have the following problem, creating controls (e.g. Button) with a FormToolkit the background and foreground color is ignored.
Normal Button:
new Button(parent, SWT.PUSH);
FormToolkit Button:
managedForm.getToolkit().createButton(parent, "search", SWT.PUSH);
This is the CSS that I use:
Button[PUSH] {
border: 1px solid #C5C5C5;
/* fancy test colors */
background-color: #0000ff;
color: #00ff00;
}
Normal Button
FormToolkit Button
This is especially bad because the hover effect is ignored as well. Is there a way to enforce the FormToolkit to also use the CSS styles?

I figured out a workaround, not the desired solution but works for now:
// hack to ensure CSS styles are used
toolkit.getColors().setBackground(null);
toolkit.getColors().setForeground(null);
If the colors are set to null, CSS style is used.

Related

How to change color of selected RadioButton in JavaFX [CSS]?

I just want to change the color of the fill circle on a RadioButton. Surprisingly I couldn't find this in documentation. Is it possible?
I found this similar thread with a solution that is not working for me: CSS Change radio button color in JFXRadioButton
Here is how I have tried it (also tried other variations to no avail):
.radio-button .radio {
-fx-selected-color: yellow;
-fx-unselected-color: blue;
}
-jfx-selected-color and -jfx-unselected-color are not defined in JavaFX. They are attributes from JFoenix (docs). Also -fx-selected-color and -fx-unselected-color are not available in JavaFX.
To change the color of the dot in the RadioButton you can use the :selected pseudoclass like this (docs):
.radio-button:selected .radio .dot {
-fx-background-color: red;
-fx-background-insets: 0;
}
Additionally to the -fx-background-color you should set -fx-background-insets: 0;, because otherwise the dot is not exactly in the center anymore.
The result will look like this:

CSS Selector for 'default' button in a javafx Alert?

in javafx, does anyone know the css selector for the color of the "default" button in an alert? The "Yes" button in light blue here:
The base color for a default button is set to the looked-up color -fx-default-button:
.button:default {
-fx-base: -fx-default-button;
}
which defaults to the light blue in your screenshot:
.root {
/* ... */
-fx-default-button: #ABD8ED;
/* ... */
}
(Code snippets from modena.css source.)
So you can just change the value of -fx-default-button on your root element.

How to style Accelerator display text in JavaFX ContextMenu via CSS?

This CSS code changes the text color of the whole text of a MenuItem:
.context-menu .label {
-fx-text-fill: blue;
}
The thing is that I only want to change the Accelerator display text.
The CSS reference of JavaFX was not very helpful: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#contextmenu
So how can you set the style of the Accelerator display text in a ContextMenu using CSS?
I inspected the skin and found out the accelerator-text class is assigned to the Label that displays the accelerator, which means you can use
.context-menu .accelerator-text {
-fx-text-fill: blue;
}
to style the Label displaying the accelerator.
I just gave a menuItem an id
fxml:
<MenuItem id="menuItem" mnemonicParsing="false" text="Close" accelerator="Shortcut+C"/>
and tried:
css:
#menuItem>Label {
-fx-background-color: #0093ff;
-fx-text-fill: #ffff00;
}
and it worked.

How to removeunderline on hover in Submenu in Oracle ADF Alta theme

How to remove underline on hover in Submenu in Oracle ADF in Alta theme.
I have tried this ADF selector and CSS but it is not working:
af|commandMenuItem:hover {
text-decoration:none;
}
and
.AFMenuItem:alias {
text-decoration:none;
}
I have also added costume class but it not works. background-color style work but text-decoration not working.
Which selector I have to use to remove underline from hover submenu?
Thanks in advance.

JavaFx Button adds ellipsis when rendered on a E4 ToolControl

I've an E4 application which has a ToolControl, the class that handles the tool control creates a JavaFX button, for some reason the button adds ellipsis and I've no clue why.
Here is the link to the sample application
https://github.com/SDSethia/ColoredButton.git
JavaFX shortens the label automatically, when the size of the control (a button in your case) is too small for the text. This is independent of E4. So if you increase the size of the button, the complete text will show.
I looked at your project and I am wondering why you are using the SWT renderers, although you want to use JavaFX!
If you want to use E4 + JavaFX I recommend to use the e(fx)clipse renderers. This tutorial should get you started: https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial4
The button needs a layout (I wrapped mine in an HBox) for it to render correctly. Here is the modified code
final FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
button = new Button();
button.setText("FxButton (1)");
button.setStyle("-fx-background-color: #186dee; -fx-text-fill: white;");
final HBox box = new HBox();
box.getChildren().add(button);
final Scene scene = new Scene(box);
canvas.setScene(scene);
This solved the issue.

Categories

Resources