sshahine / JFoenix

JavaFX Material Design Library
MIT License
6.29k stars 1.06k forks source link

Using the JFXColorPicker without the button. Possible? #1154

Open SKeeneCode opened 3 years ago

SKeeneCode commented 3 years ago

I have a treeview holding many colored labels. I want to be able to launch the color picker dialog when I click on these controls and bind the color picker value to my controls background:

image

I can launch the dialog itself easy enough (using TornadoFX here):

onRightClick {
           JFXCustomColorPickerDialog(currentStage).show()
}

But I have no way as far as I can tell, to access the value property so I can get the color result (infact, launching the dialog like this then exiting it causes a NPE).

Is it possible to get around this?

sshahine commented 3 years ago

Hi, there is a workaround for this. try the following code snippet

JFXColorPicker picker = new JFXColorPicker();
picker.setManaged(false);
JFXButton btn = new JFXButton("Show");
btn.setOnAction((action) -> picker.show());
root.getChildren().addAll(picker, btn);