-1

I'm trying to create an application where the theme or background color of the application changes on changing the slider position. The color changes within specific range of hex color codes. For example: In Dark mode of an application, if I move the slider then background color changes to different shades of dark mode either brighter shades or darker shades of dark mode

  • Bind the background to the value of the slider? – dan1st Dec 25 '19 at 15:25
  • 1
    Then listen to the value of the `Slider` and change the background color accordingly. Note you've failed to ask an actual question. If you're having a _specific_ problem then please [edit] your question to provide a [mre] demonstrating said problem—see [ask] for more information. – Slaw Dec 25 '19 at 15:25
  • @Slaw I think bindings would be more elegant... – dan1st Dec 25 '19 at 15:28
  • @dan1st Possibly. Though I believe you'd still have to use something like `Bindings#createObjectBinding(Callable,Observable...)`. – Slaw Dec 25 '19 at 15:34
  • Invoking `bindBidirectional()`, suggested [here](https://stackoverflow.com/a/55427307/230513), should work. – trashgod Dec 26 '19 at 19:21
  • use the getValue() method of the slider call .addListener(observable->{//} – Alex Dec 27 '19 at 10:02

1 Answers1

0

use the valueProperty() method of the slider call .addListener(observable->{}) and in the {} set the background color according to the getValue() value of the slider. How you convert value to background color is left for u to figure out.

Alex
  • 521
  • 7
  • 17