Class: Java::javafx::stage::Stage

Inherits:
Object
  • Object
show all
Includes:
JRubyFX::DSL
Defined in:
lib/jrubyfx/core_ext/stage.rb

Overview

JRubyFX DSL extensions for the JavaFX Stage

Constant Summary

Constants included from JRubyFX::DSL

JRubyFX::DSL::NAME_TO_CLASSES, JRubyFX::DSL::NAME_TO_CLASS_NAME

Constants included from JRubyFX::FXImports

JRubyFX::FXImports::JFX_CLASS_HIERARCHY, JRubyFX::FXImports::LOCAL_NAME_MAP

Constants included from JRubyFX

JRubyFX::VERSION

Instance Method Summary collapse

Methods included from JRubyFX::DSL

compile_dsl, included, load_dsl, #logical_lookup, #method_missing, #self_test_lookup, write_color_method_converter, write_enum_converter, write_enum_method_converter, write_event_method

Methods included from JRubyFX::FXImports

#const_missing

Methods included from JRubyFX

#build, included, load_fx, #run_later, #with

Methods included from JRubyFX::Utils::CommonUtils

#attempt_conversion, #populate_properties, #split_args_from_properties

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JRubyFX::DSL

Instance Method Details

#[](name) ⇒ Object

call-seq:

[name] => node or nil

Returns the item in the scene with the given CSS selector, or nil if not found.

Example

stage['#my_button'] #=> Button
stage['#doesNotExist'] #=> nil


32
33
34
# File 'lib/jrubyfx/core_ext/stage.rb', line 32

def [](name)
  get_scene.lookup(name)
end

#fxml(source, options = {}) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/jrubyfx/core_ext/stage.rb', line 78

def fxml(source, options={})
  if source.is_a? String
    JRubyFX::Controller.load_fxml_only(source, self, options)
  else
    source.load_into self, options
  end
end

#fxml=(source) ⇒ Object



86
87
88
# File 'lib/jrubyfx/core_ext/stage.rb', line 86

def fxml=(source)
  fxml(source)
end

#layout_scene(*args, &code) ⇒ Object

call-seq:

layout_scene() { block } => scene
layout_scene(fill) { block } => scene
layout_scene(width, height) { block } => scene
layout_scene(width, height, fill) { block } => scene
layout_scene(width, height, depth_buffer) { block } => scene
layout_scene(hash) { block } => scene
layout_scene(fill, hash) { block } => scene
layout_scene(width, height, hash) { block } => scene
layout_scene(width, height, fill, hash) { block } => scene
layout_scene(width, height, depth_buffer, hash) { block } => scene
layout_scene(fill, hash) => scene
layout_scene(width, height, hash) => scene
layout_scene(width, height, fill, hash) => scene
layout_scene(width, height, depth_buffer, hash) => scene
layout_scene(fill) => scene
layout_scene(width, height) => scene
layout_scene(width, height, fill) => scene
layout_scene(width, height, depth_buffer) => scene

Creates a new scene with given constructor arguments (fill, width, height), sets all the properties in the hash, and calls the block on the scene.

Examples

layout_scene(fill: "white") do
  label("Hello World!")
end

layout_scene(:white) do
  label("Hello World!")
end

layout_scene do
  fill = Color::WHITE
  label("Hello World!")
end


73
74
75
76
# File 'lib/jrubyfx/core_ext/stage.rb', line 73

def layout_scene(*args, &code)
  root = code.arity == 1 ? code[node] : instance_eval(&code)
  build(Java::JavafxScene::Scene, root, *args).tap { |scene| set_scene scene }
end