class PrimaryStage extends Stage
Simple helper class for construction of primary application stages.
The primary stage has to wrap an instance of a JavaFX primary stage created by JavaFX when application is initialized.
object SimpleScalaFXApp extends JFXApp { stage = new PrimaryStage { title = "Simple ScalaFX App" scene = new Scene { root = new StackPane { padding = Insets(20) content = new Rectangle { width = 200 height = 200 fill = Color.DEEPSKYBLUE } } } } }
- Source
- JFXApp.scala
- Alphabetic
- By Inheritance
- PrimaryStage
- Stage
- Window
- EventTarget
- SFXDelegate
- EventHandlerDelegate
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new PrimaryStage()
Type Members
- type EventHandled = AnyRef { ... /* 5 definitions in type refinement */ }
- Definition Classes
- EventHandlerDelegate
- sealed trait FilterMagnet[J <: javafx.event.Event, S <: SFXDelegate[J]] extends AnyRef
Trait implementing Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
Trait implementing Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
- Definition Classes
- EventHandlerDelegate
- sealed trait HandlerMagnet[J <: javafx.event.Event, S <: SFXDelegate[J]] extends AnyRef
Trait implementing Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
Trait implementing Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
- Definition Classes
- EventHandlerDelegate
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addEventFilter[E <: Event](eventType: EventType[E], eventHandler: EventHandler[_ >: E]): Unit
Registers an event filter to this task.
Registers an event filter to this task. Registered event filters get an event before any associated event handlers.
- E
Event class
- eventType
the type of the events to receive by the filter
- eventHandler
the filter to register that will filter event
- Definition Classes
- EventHandlerDelegate
- def addEventHandler[E <: Event](eventType: EventType[E], eventHandler: EventHandler[_ >: E]): Unit
Registers an event handler to this task.
Registers an event handler to this task. Any event filters are first processed, then the specified onFoo event handlers, and finally any event handlers registered by this method. As with other events in the scene graph, if an event is consumed, it will not continue dispatching.
- E
Event class
- eventType
the type of the events to receive by the handler
- eventHandler
the handler to register that will manipulate event
- Definition Classes
- EventHandlerDelegate
- def alwaysOnTop: ReadOnlyBooleanProperty
Defines whether this
Stage
is kept on top of other windows.Defines whether this
Stage
is kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Definition Classes
- Stage
- def alwaysOnTop_=(value: Boolean): Unit
- Definition Classes
- Stage
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def buildEventDispatchChain(chain: EventDispatchChain): EventDispatchChain
Construct an event dispatch chain for this target.
Construct an event dispatch chain for this target.
- Definition Classes
- EventHandlerDelegate
- def centerOnScreen(): Unit
Sets x and y properties on this Window so that it is centered on the screen.
Sets x and y properties on this Window so that it is centered on the screen.
- Definition Classes
- Window
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def close(): Unit
Closes this Stage.
Closes this Stage.
- Definition Classes
- Stage
- val delegate: Stage
JavaFX object to be wrapped.
JavaFX object to be wrapped.
- Definition Classes
- Stage → Window → SFXDelegate
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(ref: Any): Boolean
Verifies if a object is equals to this delegate.
Verifies if a object is equals to this delegate.
- ref
Object to be compared.
- returns
if the other object is equals to this delegate or not.
- Definition Classes
- SFXDelegate → AnyRef → Any
- def eventDispatcher: ObjectProperty[EventDispatcher]
Specifies the event dispatcher for this node.
Specifies the event dispatcher for this node.
- Definition Classes
- Window
- def eventDispatcher_=(v: EventDispatcher): Unit
- Definition Classes
- Window
- def eventHandlerDelegate: EventHandled
Returns a object that implements scalafx.event.EventHandlerDelegate.EventHandled.
Returns a object that implements scalafx.event.EventHandlerDelegate.EventHandled.
- Attributes
- protected
- Definition Classes
- Window → EventHandlerDelegate
- def filterEvent[J <: Event, S <: Event with SFXDelegate[J]](eventType: EventType[J])(filter: FilterMagnet[J, S]): Subscription
Registers an event filter.
Registers an event filter. Registered event filters get an event before any associated event handlers.
Example of filtering mouse events
pane.filterEvent(MouseEvent.Any) { me: MouseEvent => { me.eventType match { case MouseEvent.MousePressed => { ... } case MouseEvent.MouseDragged => { ... } case _ => { ... } } } }
or
pane.filterEvent(MouseEvent.Any) { () => println("Some mouse event handled") }
- J
type JavaFX delegate of the event
- S
ScalaFX type for
J
type wrapper.- eventType
type of events that will be handled.
- filter
code handling the event, see examples above.
- Definition Classes
- EventHandlerDelegate
- def fireEvent(event: Event): Unit
Whether or not this Window has the keyboard or input focus.
Whether or not this Window has the keyboard or input focus.
- Definition Classes
- Window
- def focused: ReadOnlyBooleanProperty
Whether or not this Window has the keyboard or input focus.
Whether or not this Window has the keyboard or input focus.
- Definition Classes
- Window
- def forceIntegerRenderScale: BooleanProperty
Boolean property that controls whether only integer render scales are set by default by the system when there is a change in the associated output scale.
Boolean property that controls whether only integer render scales are set by default by the system when there is a change in the associated output scale. The
renderScale
properties will be updated directly and simultaneously with any changes in the associatedoutputScale
properties, but the values can be overridden by subsequent calls to thesetRenderScale
setters or through appropriate use of binding. This property will not prevent setting non-integer scales directly using therenderScale
property object or the convenience setter method.Default value is false
- Definition Classes
- Window
- Since
9
- See also
- def forceIntegerRenderScale_=(forced: Boolean): Unit
- Definition Classes
- Window
- def fullScreen: ReadOnlyBooleanProperty
Specifies whether this Stage should be a full-screen, undecorated window.
Specifies whether this Stage should be a full-screen, undecorated window.
- Definition Classes
- Stage
- def fullScreenExitHint: ObjectProperty[String]
- Definition Classes
- Stage
- def fullScreenExitHint_=(value: String): Unit
- Definition Classes
- Stage
- def fullScreenExitKey: ObjectProperty[KeyCombination]
Specifies the Full Screen exit key combination
Specifies the Full Screen exit key combination
- Definition Classes
- Stage
- def fullScreenExitKey_=(value: KeyCombination): Unit
- Definition Classes
- Stage
- def fullScreen_=(value: Boolean): Unit
- Definition Classes
- Stage
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def handleEvent[J <: Event, S <: Event with SFXDelegate[J]](eventType: EventType[J])(handler: HandlerMagnet[J, S]): Subscription
Registers an event handler.
Registers an event handler. The handler is called when the node receives an Event of the specified type during the bubbling phase of event delivery.
Example of handling mouse events
pane.handleEvent(MouseEvent.Any) { me: MouseEvent => { me.eventType match { case MouseEvent.MousePressed => ... case MouseEvent.MouseDragged => ... case _ => {} } } }
or
pane.handleEvent(MouseEvent.Any) { () => println("Some mouse event handled") }
- J
type JavaFX delegate of the event
- S
ScalaFX type for
J
type wrapper.- eventType
type of events that will be handled.
- handler
code handling the event, see examples above.
- returns
Returns a subscription that can be used to cancel/remove this event handler
- Definition Classes
- EventHandlerDelegate
- def hashCode(): Int
- returns
The delegate hashcode
- Definition Classes
- SFXDelegate → AnyRef → Any
- def height: ReadOnlyDoubleProperty
The height of this Stage.
The height of this Stage.
- Definition Classes
- Window
- def height_=(h: Double): Unit
- Definition Classes
- Window
- def hide(): Unit
Attempts to hide this Window by setting the visibility to false.
Attempts to hide this Window by setting the visibility to false.
- Definition Classes
- Window
- def iconified: ReadOnlyBooleanProperty
Defines whether the Stage is iconified or not.
Defines whether the Stage is iconified or not.
- Definition Classes
- Stage
- def icons: ObservableList[Image]
Gets the icon images to be used in the window decorations and when minimized.
Gets the icon images to be used in the window decorations and when minimized.
- Definition Classes
- Stage
- def initModality(modality: Modality): Unit
Specifies the modality for this stage.
Specifies the modality for this stage.
- Definition Classes
- Stage
- def initOwner(owner: Window): Unit
Specifies the owner Window for this stage, or null for a top-level, unowned stage.
Specifies the owner Window for this stage, or null for a top-level, unowned stage.
- Definition Classes
- Stage
- def initStyle(style: StageStyle): Unit
Specifies the style for this stage.
Specifies the style for this stage.
- Definition Classes
- Stage
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def maxHeight: Double
Defines the maximum height of this Stage.
Defines the maximum height of this Stage.
- Definition Classes
- Stage
- def maxHeight_=(h: Double): Unit
- Definition Classes
- Stage
- def maxWidth: Double
Defines the maximum width of this Stage.
Defines the maximum width of this Stage.
- Definition Classes
- Stage
- def maxWidth_=(w: Double): Unit
- Definition Classes
- Stage
- def maximized: ReadOnlyBooleanProperty
Defines whether the Stage is maximized or not.
Defines whether the Stage is maximized or not.
- Definition Classes
- Stage
- def maximized_=(value: Boolean): Unit
- Definition Classes
- Stage
- def minHeight: Double
Defines the minimum height of this Stage.
Defines the minimum height of this Stage.
- Definition Classes
- Stage
- def minHeight_=(h: Double): Unit
- Definition Classes
- Stage
- def minWidth: Double
Defines the minimum width of this Stage.
Defines the minimum width of this Stage.
- Definition Classes
- Stage
- def minWidth_=(w: Double): Unit
- Definition Classes
- Stage
- def modality: Modality
Retrieves the modality attribute for this stage.
Retrieves the modality attribute for this stage.
- Definition Classes
- Stage
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def onCloseRequest: ObjectProperty[EventHandler[WindowEvent]]
Called when there is an external request to close this Window.
Called when there is an external request to close this Window.
- Definition Classes
- Window
- def onCloseRequest_=(v: EventHandler[WindowEvent]): Unit
- Definition Classes
- Window
- def onHidden: ObjectProperty[EventHandler[WindowEvent]]
Called just after the Window has been hidden.
Called just after the Window has been hidden.
- Definition Classes
- Window
- def onHidden_=(v: EventHandler[WindowEvent]): Unit
- Definition Classes
- Window
- def onHiding: ObjectProperty[EventHandler[WindowEvent]]
Called just prior to the Window being hidden.
Called just prior to the Window being hidden.
- Definition Classes
- Window
- def onHiding_=(v: EventHandler[WindowEvent]): Unit
- Definition Classes
- Window
- def onShowing: ObjectProperty[EventHandler[WindowEvent]]
Called just prior to the Window being shown, even if the menu has no items to show.
Called just prior to the Window being shown, even if the menu has no items to show.
- Definition Classes
- Window
- def onShowing_=(v: EventHandler[WindowEvent]): Unit
- Definition Classes
- Window
- def onShown: ObjectProperty[EventHandler[WindowEvent]]
Called just after the Window is shown.
Called just after the Window is shown.
- Definition Classes
- Window
- def onShown_=(v: EventHandler[WindowEvent]): Unit
- Definition Classes
- Window
- def opacity: DoubleProperty
Defines the opacity of the Stage as a value between 0.0 and 1.0.
Defines the opacity of the Stage as a value between 0.0 and 1.0.
- Definition Classes
- Window
- def opacity_=(v: Double): Unit
- Definition Classes
- Window
- def outputScaleX: ReadOnlyDoubleProperty
The scale that the
Window
will apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.The scale that the
Window
will apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screen
which may be before or after the Screen property is updated. - In response to a change in user preferences for output scaling.
- Definition Classes
- Window
- Since
9
- See also
- def outputScaleX_=(value: Double): Unit
- Definition Classes
- Window
- def outputScaleY: ReadOnlyDoubleProperty
The scale that the
Window
will apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.The scale that the
Window
will apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screen
which may be before or after the Screen property is updated. - In response to a change in user preferences for output scaling.
- Definition Classes
- Window
- Since
9
- See also
- def outputScaleY_=(value: Double): Unit
- Definition Classes
- Window
- def owner: Option[Window]
Retrieves a scala.Some with the owner Window for this stage, or scala.None for an unowned stage.
Retrieves a scala.Some with the owner Window for this stage, or scala.None for an unowned stage.
- Definition Classes
- Stage
- def removeEventFilter[E <: Event](eventType: EventType[E], eventHandler: EventHandler[_ >: E]): Unit
Unregisters a previously registered event filter from this task.
Unregisters a previously registered event filter from this task. One filter might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the filter.
- E
Event class
- eventType
the event type from which to unregister
- eventHandler
the filter to unregister
- Definition Classes
- EventHandlerDelegate
- def removeEventHandler[E <: Event](eventType: EventType[E], eventHandler: EventHandler[_ >: E]): Unit
Unregisters a previously registered event handler from this task.
Unregisters a previously registered event handler from this task. One handler might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the handler.
- E
Event class
- eventType
the event type from which to unregister
- eventHandler
the handler to unregister
- Definition Classes
- EventHandlerDelegate
- def renderScaleX: DoubleProperty
The horizontal scale that the
Window
will use when rendering itsScene
to the rendering buffer.The horizontal scale that the
Window
will use when rendering itsScene
to the rendering buffer. This property is automatically updated whenever there is a change in the outputScaleX property and can be overridden either by callingsetRenderScaleX()
in response to a listener on theoutputScaleX
property or by binding it appropriately.Default value is outputScaleX
- Definition Classes
- Window
- Since
9
- See also
- def renderScaleX_=(scale: Double): Unit
- Definition Classes
- Window
- def renderScaleY: DoubleProperty
The vertical scale that the
Window
will use when rendering itsScene
to the rendering buffer.The vertical scale that the
Window
will use when rendering itsScene
to the rendering buffer. This property is automatically updated whenever there is a change in the outputScaleY property and can be overridden either by callingsetRenderScaleY()
in response to a listener on theoutputScaleY
property or by binding it appropriately.DefaultValue is outputScaleY
- Definition Classes
- Window
- Since
9
- See also
- def renderScaleY_=(scale: Double): Unit
- Definition Classes
- Window
- def requestFocus(): Unit
Requests that this Window get the input focus.
Requests that this Window get the input focus.
- Definition Classes
- Window
- def resizable: BooleanProperty
Defines whether the Stage is resizable or not by the user.
Defines whether the Stage is resizable or not by the user.
- Definition Classes
- Stage
- def resizable_=(v: Boolean): Unit
- Definition Classes
- Stage
- def scene: ReadOnlyObjectProperty[Scene]
The Scene to be rendered on this Stage.
The Scene to be rendered on this Stage.
- Definition Classes
- Window
- def scene_=(s: Scene): Unit
Specify the scene to be used on this stage.
Specify the scene to be used on this stage.
- Definition Classes
- Stage
- def show(): Unit
Attempts to show this Window by setting visibility to true.
Attempts to show this Window by setting visibility to true.
- Definition Classes
- Stage
- def showAndWait(): Unit
Shows this stage and waits for it to be hidden (closed) before returning to the caller.
Shows this stage and waits for it to be hidden (closed) before returning to the caller. This method temporarily blocks processing of the current event, and starts a nested event loop to handle other events. This method must be called on the FX Application thread.
- Definition Classes
- Stage
- def showing: ReadOnlyBooleanProperty
Whether or not this Stage is showing (that is, open on the user's system).
Whether or not this Stage is showing (that is, open on the user's system).
- Definition Classes
- Window
- def showing_=(v: Boolean): Unit
Attempts to show or hide this Window.
Attempts to show or hide this Window.
- Definition Classes
- Stage
- def sizeToScene(): Unit
Set the width and height of this Window to match the size of the content of this Window's Scene.
Set the width and height of this Window to match the size of the content of this Window's Scene.
- Definition Classes
- Window
- def style: StageStyle
Retrieves the style attribute for this stage.
Retrieves the style attribute for this stage.
- Definition Classes
- Stage
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def title: StringProperty
Defines the title of the Stage.
Defines the title of the Stage.
- Definition Classes
- Stage
- def title_=(v: String): Unit
- Definition Classes
- Stage
- def toBack(): Unit
Send the Window to the background.
Send the Window to the background.
- Definition Classes
- Stage
- def toFront(): Unit
Bring the Window to the foreground.
Bring the Window to the foreground.
- Definition Classes
- Stage
- def toString(): String
- returns
Returns the original delegate's
toString()
adding a[SFX]
prefix.
- Definition Classes
- SFXDelegate → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def width: ReadOnlyDoubleProperty
The width of this Stage.
The width of this Stage.
- Definition Classes
- Window
- def width_=(w: Double): Unit
- Definition Classes
- Window
- def x: ReadOnlyDoubleProperty
The horizontal location of this Stage on the screen.
The horizontal location of this Stage on the screen.
- Definition Classes
- Window
- def x_=(value: Double): Unit
- Definition Classes
- Window
- def y: ReadOnlyDoubleProperty
The vertical location of this Stage on the screen.
The vertical location of this Stage on the screen.
- Definition Classes
- Window
- def y_=(value: Double): Unit
- Definition Classes
- Window
- object FilterMagnet
Companion object implementing Magnet Pattern Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
Companion object implementing Magnet Pattern Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
- Definition Classes
- EventHandlerDelegate
- object HandlerMagnet
Companion object implementing Magnet Pattern Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
Companion object implementing Magnet Pattern Magnet Pattern to avoid compilation error "ambiguous reference to overloaded definition"
- Definition Classes
- EventHandlerDelegate
ScalaFX is a UI DSL written within the Scala Language that sits on top of JavaFX 2.x and and JavaFX 8. This means that every ScalaFX application is also a valid Scala application. By extension it supports full interoperability with Java and can run anywhere the Java Virtual Machine (JVM) and JavaFX 2.0 or JavaFX 8 are supported.
Package Structure
ScalaFX package structure corresponds to JavaFX package structure, for instance
scalafx.animation
corresponds tojavafx.animation
.Example Usage
A basic ScalaFX application is created creating an object that is an instance of
JFXApp
. Following Java FX theatre metaphor, it contains astage
that contains ascene
. Astage
roughly corresponds to a window in a typical UI environment. Thescene
holds UI content presented to the user. In the example below, the content is a pane with a singlelabel
component.