JavaFX-2 FXML CSS Reflection

2019-07-07 04:23发布

Is it possible to use the javafx.scene.effect.Reflection in CSS for a FXML file?

And something more general (I haven't found any answer for that yet): Can I do everthing with FXML and CSS that is available on the Java API (using JavaFX 2.2)?

标签: javafx-2
1条回答
我想做一个坏孩纸
2楼-- · 2019-07-07 05:21

Is it possible to use the javafx.scene.effect.Reflection in CSS for a FXML file?

Not for JavaFX 2.2 - only dropshadow and innershadow effects can be set via CSS. Future JavaFX versions will probably add the ability to set more effects via CSS.

For now if you want an effect like that in combination with FXML, then you can use a Controller or define the effect in FXML without using CSS.

For example:

<Button layoutX="20.0" layoutY="32.0" text="Reflected Button">
  <effect>
    <Reflection />
  </effect>
</Button>

To visually design and define your FXML based effects, use SceneBuilder, click on your Node, go to the Properties Pane and select an effect to customize from the Effect drop down box.

Can I do everthing with FXML and CSS that is available on the Java API (using JavaFX 2.2)?

You will still need to write some non-fxml embedded code to launch the app and load up your fxml.

If you use FXML's scripting feature you could do most of what can be done on the Java API. For ease of maintenance, I would however recommend using an FXML Controller or hosting script code external from your fxml files rather than embedding it in the fxml.

查看更多
登录 后发表回答