splitPane change listener

31 views
Skip to first unread message

Bene Volent

unread,
Nov 28, 2019, 3:33:17 PM11/28/19
to ScalaFX Users
How to implement a change listener for a splitPane?

Having doubts based on some practices, which do not seem to work this far.

def dvListener (splitp:SplitPane) {
// "Cannot resolve overloaded method addListener"
splitp.dividers.addListener {
(o: javafx.beans.value.ObservableValue[_ <: Number], oldVal: Number, newVal: Number) => {
// conditions to capture the variation or whatever
val divposit = newVal
if ... {
println("Position changed:" + divposit)
        ...
        ...
}
}
} // end addListener
} // END dvListener

Issue seems to be with implementation of addListener. What am I missing?
thanks.


Jarek Sacha

unread,
Dec 2, 2019, 10:57:25 PM12/2/19
to scalaf...@googlegroups.com

You can treat dividers as an ObservableBuffer and use onChange to listen to changes:

splitp.dividers.onChange{ (buffer, changes) =>
  ...
}

There is a complete example here:
https://github.com/scalafx/ProScalaFX/blob/master/src/proscalafx/ch06/BufferChangeEventExample.scala

Jarek

--
You received this message because you are subscribed to the Google Groups "ScalaFX Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalafx-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalafx-users/419aaec8-3e40-42a1-aad0-daa057870f8d%40googlegroups.com.

Bene Volent

unread,
Dec 3, 2019, 3:57:36 PM12/3/19
to scalaf...@googlegroups.com
Thanks, it is good to see a complete implementation in that example.

Reply all
Reply to author
Forward
0 new messages