JavaFX set Button text via CSS - java

I googled for this, but couldn't find anything. I know that I can style a Buttons text, background colour etc, but I would like to change the text itself.
This is what I've tried (of course the actual end result is more complex, but this will do):
Button#playButton {
-fx-background-color: #ddd;
-fx-text: "Play";
}
the background colour is correctly applied, but the text does not change.
Edit: The way to go seems to be a custom property, if someone has knowledge within that field I would love a concise explanation and implementation, that could save me hours of trial and error with the few sources I found!

No you cannot set the text of your button using css. But hey! In the other hand, you can still display an icon in your button using css!
You only need to add this to your css :
-fx-graphic : url("relative path to your icon");
In case your icon is repeated in the button, then add this as well :
-fx-background-repeat : no-repeat;

Related

JavaFX: Can a TreeView's "selector bar" be adjusted to fit content?

By "selector bar", I am referring to the selected tree-cell from when you click on a node of the TreeView. I'm using javafx8.
When an object in a TreeView is selected, the selector bar stretches to edges of whatever pane contains the aforementioned TreeView, like in the image above. What I want to achieve can be seen below.
I figured a reasonable way to achieve this would be to write a couple of css blocks. First, one that makes the current selector bar not visible, like below,
.tree-cell:selected
{
-fx-background-color: transparent;
}
in combination with a css block to make whatever node contains the icon and label some background color. I can't find a resource that lists the substructure of the TreeView or TreeCell; I did not see much here, and there were no related google search results other than the documentation linked. Maybe I'm not looking in the right place? Anyway, I would imagine a second block would go something like below
.tree-cell:selected > .hbox
{
-fx-background-color: blue;
}
where hbox should be replaced with whatever node contains the icon and label. If anyone could tell me what information I'm missing, or perhaps this is possible an entirely different way? I would really appreciate any efforts.
Thank you so much for your time.

JavaFx: TreeTableView arrow reference

How can I get a reference to the expand/collapse "arrow" in a TreeTableView?
I cannot provide any code, since, I didn't really know what to look for.
Here is an image that shows what I need. The highlighted arrows are which I need.
I want to remove it, while keeping the collapse/expand mechanism(which works also if I click on the row itself), or making it transparent via css.
Set the background of the arrow to transparent via CSS stylesheet. The CSS below contains code for both TreeTableView and TreeView, since you write about TreeTableView but your screenshot shows a TreeView:
.tree-cell .arrow,
.tree-table-row-cell .arrow {
-fx-background-color: transparent;
}

JavaFX 2.2 Remove Pagination's selected page label

I want to remove the Selected page label (see image below) of the Pagination control.
After digging into caspian.css I wasn't able to find any clue about how to do that. By code I also didn't find any method to remove (or eventually hide) this label.
Is there a way to do that in JavaFX without re-implementing the whole control ?
Use -fx-page-information-visible
It's described within these links:
http://docs.oracle.com/javafx/2/ui_controls/pagination.htm
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pagination.htm#JFXUI459
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#pagination
I couldn't find a way either to hide just the label, but would it help to hide the whole button?
.number-button:selected{
-fx-opacity: 0;
}
That would hide the current selected button.
It's not what you actually wanted but maybe it can help you.

Css menu becomes transparent over javascript

I'm trying to implement a css menu in a website, and have run into a problem.
Note: The css is in the file, it's the only thing under The javascript is called http://w.sharethis.com/button/buttons.js and it's defined on the header as well.
The menu is called cssmenu.
The problem is, on that css menu, when hovering over contact, the background colors are transparent, and with my limited knowledge on the subject, I really don't know how to fix this.
The css menu is not my creation, I found it on the web. I have modified many properties that I knew how, but got stuck there.
You need to bump up the z-index of the main menu <ul> so it always appears over the ShareThis bar:
ul.cssmenu {
display: block;
zoom: 1;
float: left;
position:relative; /* allows the z-index to be effective -- http://www.w3.org/wiki/CSS/Properties/z-index */
z-index:100; /* makes the menu appear above the ShareThis widget */
}
If I understand your problem correctly, the issue is that the menu is positions incorrectly on the z axis.
Try adding something like this to bring it forward on top of the buttons:
.cssmenum {
z-index: 1000;
}
z-index seems to be the right solution, I have just checked now.
However I have also noticed that tabels have been used to build the menu with social icons. I suggest creating a DIV and use CSS to position it where needed.
add z-index:2;
ul.cssmenu, ul.cssmenu ul
in this class and you will get your result :-)
You have to set a ground zero for your z-index like this
body{position:relative;
z-index:0;}
Then you can give each of your menu's a z-index
.div1{z-index:1;}
.div2{z-index:5;}

JasperReports exported to Excel ignoring background color?

Have you ever had alternating background colors in a Jasper report and then exported it to Excel? The Excel export seems to ignore the alternating color.
I've got a Jasper report where the rows alternating background color using the procedure referenced HERE. When I preview it using the viewer or export to PDF it works -- but not when I export to Excel. I've tried using JRXlsExporter and JExcelApiExporter both to no avail.
I think it might be a side-effect of how you have to make alternating row colors in Jasper, which I despise to begin with, but have found no other way.
Thanks in advance!
Also, Be sure that the conditional styles you make, have the "opaque" option checked... If not, the background color will never apper in the excel report (never!!!)....
Also, The "opaque" option must be checked in the text fields....
And if you noticed that the text fields never took the style that you gave to them, try to set the forecolor and background to null, in the properties panel of each text field (this works for me)...
Hope this help... bye.
Did you try the idea suggested in the comment of the very procedure you are referring to ?
First how to create new report style with condition:
Recent releases of JasperReports include report styles, which make this a bit easier - you no longer have to create the rectangle.
I use iReport to create my styles - there is a “styles” pane that by default is docked with the “Library” pane. If you make it visible you can create a new style in the styles library. In the screen that pops up give the style a name (say “EvenOddRowStyle” and press “Add” under “Style Conditions”. Use one of the expressions that Brian gave and press Apply. and in the “Common” section press the “…” button next to “Backcolor” and pick the background color you want. Finally, when done with your report apply that style to all the fields in the rows you want to highlight. Just drag the style from the styles pane onto the field.
Then how to define a style which will be applied when exported to Excel:
defining a new style with the condition expression:
Boolean.valueOf( $V{PAGE_COUNT}.intValue() % 2 == 0 )
on it without using a rectangle and a print when expression on it!

Categories

Resources