当前位置: 动力学知识库 > 问答 > 编程问答 >

JavaFX-2 FXML CSS Reflection

问题描述:

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)?

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: