Tony,
tabs is intended to be used as ScalaFX ObservableBuffer, so can be modified directly. But the current code does not provide type annotation, so it may not be obvious. I added this as an issue in the repo (#324).
Since you can manipulate tabs as a collection, the assignment was probably added to make it easier to reassign compete content of tabs from a Scala collection.
Can you provide a snippet illustrating your use case of tabs to better understand what you are trying to do?
Jarek
On Mon, May 25, 2020 at 1:06 AM Tony Sloane inky...@gmail.com wrote:
import javafx.scene.control.{Tab => JavaFXTab}def componentTab(component : Component) : Option[JavaFXTab] =tabPane.tabs.find(_.userData == component)
Since tabPane.tabs is a collection of JavaFX Tabs, componentTab gives me back (an optional) one of those, instead of a ScalaFX Tab.One follow-on consequence seems to be that once I'm in the JavaFX world I am stuck there. E.g., accesses of the content of the tab I get back from componentTab doesn't give me a ScalaFX object but a JavaFX one.
Automatic type conversions (implicit conversions) only change the external type. In this case from tabs is converted from jfx.ObservableLIst[jfx.Tab] to ObservableBuffer[jfx.Tab]. Inner type is unchanged. You need to manually handle inner type conversion, when needed. When converting from JavaFX to ScalaFX just use ScalaFX constructor, like new Tab(jfxTab), that wraps JavaFX object. In your case, map to ScalaFX type:
import scalafx.scene.control.Tab
def componentTab(component : Component) : Option[Tab] =
tabPane.tabs.find(_.userData == component).map(new Tab(_))
When forcing “conversion” from ScalaFX to JavaFX you just access the wrapped JavaFX object using .delegate
Jarek