问题
I need to store entire node properties in css for any JavaFX element or mainly for javafx.scene.text.Text or javafx.scene.shape.
For Text I'm not sure how to set text value though css. Is it possible?
I need to store all properties in css so that I can easily recreate same element with applied properties with help of this css.
TIA
回答1:
According to the official CSS documentation for Text nodes this is not possible, there does not appear to be an equivalent of the web CSS content attribute which I believe you require. I find JavaFX CSS limited e.g. does not support most CSS layout properties, width, height etc.
The available properties are as follows plus those the -fx-font-* properties.
- -fx-font Font.DEFAULT inherits
- -fx-font-smoothing-type [ gray | lcd ] gray
- -fx-strikethrough false
- -fx-text-alignment [ left | center | right | justify ] left inherits
- -fx-text-origin [ baseline | top | bottom ] baseline
- -fx-underline
If you're really desperate, you could create a custom subclass of Text which supported it using CSS API to support custom UI Controls. This looks like quite a task though.
来源:https://stackoverflow.com/questions/26903054/set-text-for-javafx-scene-text-text-through-css