depending on what data I retrieve from the database, I need to update the color of a menu item. This is no problem for me, device.Style.Add("background-color", "red") works just fine for me. However, when I change the background color, it overrides my CSS style sheet, which is supposed to change the color to light grey on a:hover. Is there a way to update what the a:hover background color should be in my VB code? Thank you!!!
Use vb to attach a css class to the button. Then style that class to have the color you want.
Related
I encountered a frustrating problem with styling a javafx graph. Hope that somebody can help me out.
Using the JavaFx-library I made a StackedBarChart and a LineChart combined in one scene:
StackPane stackpane = new StackPane();
stackpane.getChildren().addAll(lineChart,stackedBarChart);
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
Style.css looks as follows:
.default-color0.chart-series-line { -fx-stroke-width: 4px;-fx-stroke: #3F48CC; -fx-stroke-dash-array: 12 12 12 12;}
.default-color0.chart-bar { -fx-bar-fill: #AA3B3B }
.default-color1.chart-bar { -fx-bar-fill: #FFC000 }
.chart-plot-background { -fx-background-color: transparent; }
The resulting image is:
Resulting image
Now I want to turn everything that is lightgrey (the background) into white. I tried that by adding the following styling:
.chart {-fx-background-color: white}
But this simple action makes the linechart (with the title of the chart) disappear:
Resulting image after adding style line
It seems that the .chart class refers to the background of the barchart, which is covering the linechart. Therefore: how to set the background of the entire image? Or should I make the background of the barchart-layer transparent and the background of the linechart-layer white? And if so: how to do that?
Thanks a lot!
If you use SceneBuilder, you can drop a control onto the design page, then click on View / Show CSS Analyser and it will open a window at the bottom that shows all of the styling properties for the selected object. If an object has multiple components on it, you can click on each one and see the related styling options.
Also, at the top of that lower window, you will see and arrow in a circle ... click on it to see more sub layer styling info that is related to whatever you have selected in the design window.
How can I style a ComboBox "body" part not the dropdown?
As you can see on the screenshot I want to style just that part where you click and opens the dropdown and the dropdown should remain as it is.
If I try for example:
.combo-box-base .list-cell{
-fx-background-color: red;
}
everything goes red not just what I want.
I had a look at this question: Javafx combobox styling
but it didnt really helped me, it styles everything but not that specific part I need.
I have also looked with ScenicView, and I could locate it and add as style: -fx-background-color: red and it worked, but from code I could't manage it.
In ScenicView I saw the ComboBox has three components:
a StackPane a ListView and a ListCell. I want to style just the ListCell part.
Here is how it looks like if I add those line in my.css:
As you can see I don't want the dropdown to be styled.
How can I solve it.
Note: the arrow should remain as it is, just that part where the text is shown, as the second screenshot shows.
I need to change the very bright (almost white) color visible on the attached image and the color of the font on those TabItems being a part of white TabFolder.
I use CSS and also tried setBackground function called on Composite and TabFolder but without success. The best solution for me would be to change it via CSS if possible
There is no specific code for TabFolder or TabItem in the Eclipse CSS support so they just get the CSS common to all controls such as background-color and color.
color does seem to change the color of the tab folder tab text, background-color does not change the tab background (it changes the background of the rest of the control).
The Eclipse CSS support works by calling normal SWT methods in the controls, since TabFolder does not have methods to set the tab background there is no way this can be done.
CTabFolder is much more flexible and allows new tab renderers to be used which can extend the CSS. Also note that on some platforms CTabFolder looks substantially different from TabFolder (macOS in particular).
You can use CSS classes and ids to restrict your CSS to just your folders. For example in your code use:
CSSUtil.setCSSClass(folder, "my-folder-class");
to set the CSS class of a folder and in the CSS use the class:
CTabFolder.my-folder-class
{
swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
swt-shadow-visible: false;
swt-simple: false;
swt-tab-height: 22px;
swt-unselected-tabs-color: black;
swt-selected-tab-fill: black;
swt-outer-keyline-color: black;
swt-tab-outline: black;
swt-shadow-color: black;
swt-unselected-hot-tab-color-background: #2F2F2F;
swt-selected-tabs-background: black black 100%;
color: rgb(128, 128, 128);
}
This CSS also shows the use of the standard Eclipse custom tab folder renderer. This is just an example taken from a dark theme for one of my own RCPs.
How can i create a Toolbar like this:
LINK: http://s14.postimg.org/99095jk3l/image.png
I already created a toolbar with the correct background. My only problem are the buttons.
I dont know how to style the buttons to be transparant, and how to add the correct on hover and on click effects to match the background.
Thanks in advance
You'll be working with CSS. You can set the background and border to transparent, then have a hover class for adding a semi-transparent border. It would end up being something like this (Please note, you may have to make some tweaks still)
.button {
-fx-background-color: transparent, transparent, transparent, transparent;
}
.button:hover{
-fx-background-color: transparent, rgba(0,0,0,.1), rgba(0,0,0,.1), transparent;
}
.button:armed {
-fx-background-color: transparent, rgba(0,0,0,.1), rgba(0,0,0,.1), rgba(0,0,0,.2);
}
To apply the style sheet you'd use code similar to this:
toolbar.getStylesheets().add("filename.css");
There are lots of good references for this in the "Info" section of the "javafx-2" tag. Here are a few that should prove helpful with this:
JavaFX 2 CSS Reference Guide
caspian.css for JavaFX 2.2 (The default style sheet)
I've got a web page with an applet inside. This applet is a drop target on a drag and drop action from the OS, I simply take an image from a folder, drag it on the applet and something happens.
I give this webpage to a graphic designer and he ask to if he can put an image behind the java applet so he can simulate to change the background using CSS (it is a skinned app and graphic design can change during execution).
Practically i supposed to do:
<div>
<applet width="50" height="50" />
</div>
with this CSS:
div {
width:50px;
height:50px;
background-image: url(image.jpg) center center no-repeat;
}
But it doesn't work (background is opaque).
It is possible to set transparency to the applet without loosing drag and drop capabilities ?
I'm searching something similar to flash wmode parameter.
Better solutions implies only changes on the CSS/HTML without recompiling java class so the designing team can change the page structure without changing the Java.
You might pass the background image URL into the applet as a parameter, or have the applet use Javascript to interrogate the page to determine what background image is shown.
It is not possible to make an applets background transparent, but you can use the alpha parameter of color to set transparency on components of the applet and to get the same background as the website you could pass the color or image as an applet parameter. However if it's an image, it will probably not be aligned like the site unless you position it fixed and pass the right part of the image.
You can try to put your applet code in a <td> tag of a <table>, and set background-color property of that <td> to your desired color, the applet will be displayed under that color only.