ScalaFX 8.0.40-SNAPSHOT + Spinner
November 8, 2014
Posted by on Upcoming release of JavaFX 8u40 will bring several enhancements, including dialogs and new spinner control. ScalaFX started new branch, SFX8u40, to support JavaFX 8u40. One of the first things added is Spinner. A spinner is a single line text field that lets the user select a number or an object value from an ordered sequence. There are predefined Spinner classes for holding values of Integer, Double, and List of arbitrary values.
Here is a sample ScalaFX code that generates above Spinners for Integers, Doubles, and lists of Strings
import scalafx.application.JFXApp import scalafx.application.JFXApp.PrimaryStage import scalafx.collections.ObservableBuffer import scalafx.geometry.Insets import scalafx.scene.Scene import scalafx.scene.control.Spinner import scalafx.scene.layout.{HBox, VBox} /** * A sample that demonstrates the Spinner control. */ object SpinnersDemo extends JFXApp { val styles = Seq( "spinner", // defaults to arrows on right stacked vertically Spinner.StyleClassArrowsOnRightHorizontal, Spinner.StyleClassArrowsOnLeftVertical, Spinner.StyleClassArrowsOnLeftHorizontal, Spinner.StyleClassSplitArrowsVertical, Spinner.StyleClassSplitArrowsHorizontal ) val intSpinners = for (s <- styles) yield new Spinner[Integer](1, 99, 5) { styleClass += s prefWidth = 100 } val stringSpinners = for (s <- styles) yield new Spinner[String](ObservableBuffer("Grace", "Matt", "Katie")) { styleClass += s prefWidth = 100 } val doubleSpinners = for (s <- styles) yield new Spinner[Double](0.0, 1.0, 0.5, 0.01) { styleClass += s prefWidth = 100 } stage = new PrimaryStage { title = "Spinners Demo" scene = new Scene { content = new VBox(30) { content = Seq( new HBox(30, intSpinners: _*), new HBox(30, doubleSpinners: _*), new HBox(30, stringSpinners: _*) ) padding = Insets(24) } } } }
To take a SNAPSHOT for a spin add following to your SBT build file:
libraryDependencies += "org.scalafx" %% "scalafx" % “8.0.40-SNAPSHOT”
Recent Comments