1

I have a problem with styling JFXButton from this library : jfoenix.com

I would like to change the JFXButton Rippler Fill Color, when user click a button. But it's not working. I checked on the internet. But a solution could not be found. Have you to any ideas?

@FXML
private void settingApplyBtnAction(ActionEvent event) {

 //option 1
 paymentBtn.setStyle("-jfx-rippler-fill: " + themeColor);
 //option 2
 paymentBtn.setStyle("-fx-rippler-fill: " + themeColor);

 /*other code....*/

}

But if I give a color from SceneBuilder, it's working fine. Anyone can help me.

fabian
  • 80,457
  • 12
  • 86
  • 114
SUDESH KUMARA
  • 891
  • 9
  • 18
  • Do you want to change your Rippler color from the java code and you want to see the result in scene builder when you add a target method to your method ,or it does not give you any effects in runtime. ? – Menai Ala Eddine - Aladdin Oct 01 '18 at 14:31
  • 1
    I think you'd be better off using css to control your theme. The `JFXRippler` on a button is probably on a `StackPane` or some other node type inside the `JFXButton`. Use the `.jfx-rippler` class to specify the `-jfx-rippler-fill` property. You can use a separate css file for each theme. – RonSiven Oct 01 '18 at 19:38
  • Menai Ala Eddine & RonSiven. Thank you both for your time sharing with me. – SUDESH KUMARA Oct 02 '18 at 15:25

1 Answers1

4

If you must use code to change your theme, try using the setRipplerFill method on the JFXButton class.

@FXML
private void settingApplyBtnAction(ActionEvent event) {

    paymentBtn.setRipplerFill(Color.valueOf(themeColor));

    /*other code....*/

}
RonSiven
  • 939
  • 2
  • 10
  • 23
  • Mr.RonSiven Thank You So Much.... That's what I really expected. Unfortunately, I do not have the enough reputation to give a vote. But I recommend this answer to every user. Thanks again Mr.RonSiven. – SUDESH KUMARA Oct 02 '18 at 15:19
  • You're welcome. You should be allowed to mark this as the accepted answer, though. Just click the check mark. :) – RonSiven Oct 02 '18 at 20:10