set text for javafx.scene.text.Text through css

心不动则不痛 提交于 2019-12-14 03:57:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!