How can I change the size and color of the text for the ControlsFX segmented bar? The usual way:
-fx-font-size: 15px
Doesn’t seem to work.
It doesn’t matter to me whether I change this using a CSS stylesheet or through the code. I have tried both. -fx-background-color: does work, so my styling is having an effect.
I just can’t seem to find anywhere, or intuitively figure out the correct CSS for how to style the text of the segmented bar control.
Thanks!
ControlsFX uses a default SegmentViewFactory that uses a class called SegmentView with a style class segment-view, so this is the way to style a text in a SegmentedBar:
.segment-view {
-fx-font-size: 15px;
}
Another way to style the text in a SegmentedBar is to use a custom SegmentViewFactory. Here is an example:
SegmentedBar<Segment> bar = new SegmentedBar<>();
bar.getSegments().addAll(
new Segment(2.46, "Apple"),
new Segment(2.43, "Microsoft"),
new Segment(1.94, "Alphabet"),
new Segment(1.72, "Amazon"));
bar.setOrientation(Orientation.HORIZONTAL);
bar.setSegmentViewFactory(segment -> {
Label viewNode = new Label(String.format("%s (%.2fT)", segment.getText(), segment.getValue()));
viewNode.setStyle("-fx-font-size: 15px; -fx-font-style: italic;");
return viewNode;
});
Related
I have quite long Strings in one column and I want to display them as multi-line cells in my grid.
I'm using Vaadin 14 + Java and I tried to set CSS-Style Class for the specific column:
Java-Code:
#CssImport("./styles/shared-styles.css")
public class RisikoGrid extends Grid<RisikoEntity> {
public RisikoGrid() {
setSizeFull();
// add the column to the grid
addColumn(Entity::getAttribute).setHeader("MyCol")
.setFlexGrow(10).setSortable(true).setKey("mycolumn");
// set CSS style class for the specific column
this.getColumnByKey("mycolumn").setClassNameGenerator(item -> {return "grid-mycol";});
}
}
CSS (shared-styles.css)
.grid-mycol{
background: red;
white-space: normal;
word-wrap: break-word;
}
While I do see the class-name when I use the inspector in my webbrowser (chrome), the css is not applied.
What do I need to change to make it work?
Edit: this is how my styles look like - and I can't even see the background:red for instance:
You can use the built-in wrap-cell-content theme variant to allow text to wrap inside the cells.
grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT);
See the last example on https://vaadin.com/components/vaadin-grid/html-examples/grid-theme-demos – the texts there are not that long, but if you make your browsers window narrow enough you’ll see some of the addresses wrap on two lines.
I looked into why my css settings didn't show up in the inspector and the solution was a minimal change from:
#CssImport("./styles/shared-styles.css")
to
#CssImport(value = "./styles/shared-styles.css", themeFor = "vaadin-grid")
I'm guessing the component scope of the grid differs from the global CSS.
It works now.
I want to style the font of the CalendarTimeTextField Popup control using a CSS File.
The following entry doesn't work for me:
.CalendarTimeTextFieldSkin_popup {
-fx-text-fill: white;
-fx-font-style: italic;
}
Setting the font-type works, changing text color doesn't.
Thanks for supporting me
GGK
The text is rendered with a Text node (https://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#text) so use -fx-fill and/or -fx-stroke.
Im very new to CSS since I was never working with weblanguages but for a JavaFX application I've got a css style sheet with a windows 10 UWP theme. The default style classes use the default windows grey button theme, but i also created a custom style class for colored components.
The colors are as variables in the the .root style class for the default style and are overwritten in the .colored style class for the colored style.
.root
{
-fill-color: #CCCCCC;
...
}
.colored
{
-fill-color: #DD2867;
...
}
I now want to change the colored style colors at runtime.
I know about Node#setStyle(String) in which i can modify the fill color with something like this:
root.setStyle("-fill-color: #FF00FF;");
but this has only an effect on the color in the .root style class and not the .colored style class.
Can you tell me a way to direcly modify a property of a style class at runtime or maybe an even better approach to use a default and a colored style?
Thanks in advance,
Eleom.
Define another looked-up color on the root node, and use it in your .colored class:
{
-fill-color: #CCCCCC;
-colored-fill: #DD2867 ;
...
}
.colored
{
-fill-color: -colored-fill;
...
}
Then you can change that color programmatically the same way:
root.setStyle("-colored-fill: ... ;");
So I have the following code snipet which I want applied to 99% of my labels in my JavaFX application. However, sometimes I don't want it applied. Unfortunately whenever I try to call
myFont.setFont(Font.loadFont(etc etc);
It is unable to override the label class in the CSS file. How can this be done? Thank you!
.label
{
-fx-font-size: 14pt;
-fx-font-family: "Segoe UI Semibold";
}
There are different ways to do it. Few of the approaches are described here :
Define a different style-class instead of using the default .label and use it on your 99% of labels.
Code :
mylabel.getStyleClass().add("my-label")
CSS :
.my-label {
-fx-font-size: 14pt;
-fx-font-family: "Segoe UI Semibold";
}
Remove the default label style class and set a new style class to 1% of the labels. This will remove the already present .label style class from the node. This seems to be an easier approach but if I were you, I would not go with this approach since we <3 the default styles and we want them to be applied to the respective nodes by default.
Code :
mylabel.getStyleClass().setAll("my-label");
.label is one of the built in styles that is applied to all Nodes of type Label. You can remove any style class like this:
Label lbl = ...
lbl.getStyleClass().remove("label");
However I would suggest another approach that does not involve removing a style class especially one of the built ins.
As there seems to be only a selected few labels, that don't have that style you can override it on those Labels:
.label-override {
-fx-font-size: 10pt;
-fx-font-family: "Segoe UI Semibold";
}
Label otherLbl = ...
otherLabel.getStyleClass().add("label-override);
I have lots of tool-tips in my SmartGWT application and now I want to change the width of each tool-tip without setting width of each individual tool-tip that is most tedious task.
I can set the width of tool-tip in SmartGWT using Canvas#setHoverWidth() but my concern is to apply this setting globally applicable for whole application.
Is there any way in SmartGWT to specify the tool-tip width globally applicable for whole application using CSS or JAVA code?
For sample code have a look at Hovers Tooltips Sample (Smart GWT).
Thanks in advance.
Finally I got the style name that is applied on all the tool-tips.
SmartGWT have a concept of Skinning that is the process of modifying Smart GWT's default look and feel to match the desired look and feel for your application.
A "skin" consists of:
a single CSS stylesheet containing all CSS styles used by Smart GWT components (skin_styles.css)
a single JavaScript file that sets component defaults (load_skin.js)
a directory tree of images organized by component
I found the style canvasHover in skin_styles.css that is used for hovering on Canvas.
I just added min-width: 135px; that changed the width of all the tool-tips globally in the application. By default it's 100px.
/* hover canvas */
.canvasHover,.gridHover,.formHover {
background-color: #fdfdd3;
border: 1px solid gray;
color: black;
font-family: Arial, Verdana, sans-serif;
font-size: 11px;
padding: 5px;
min-width: 135px;
}
Thanks a lot for your attention.
I have no idea about SmartGWT works, but for this kind of dirty things if those elements are attached to the DOM, I'd use GQuery.
Something like:
GQuery.$("#yourTooltipId or .yourTooltipClass", RootPanel.get()).each(new Function() { public void f(Element e){
GQuery.$(e).width(30);
}});
Instead of RootPanel.get(), you can use other scope if for any reason you have all the tool-tips under the same view.