-
Notifications
You must be signed in to change notification settings - Fork 29
Extensions
This page lists all the JRubyFX-specific extensions for JavaFX. Almost all JavaFX code should work identically in Ruby, but there are provided for convenience and to make JavaFX look more rubyish. This does not go over JRuby extensions, like jobj.var = foo mapping to jobj.setVar(foo). See the JRuby wiki for those. Basic knowledge of Ruby is assumed
The Number class provides sec, ms, min, hr, and hrs methods that return JavaFX Durations. They are most likely to be used in animations:
timeline do
animate foo_property, 0.sec => 5.sec, from => to
endObservableValues, ObservableLists, and ObservableMaps all add a new method add_change_listener that registers the provided block via addListener(*ChangeListener) without warnings. ObservableValue's also provide a short version when only one block argument is given (arity 1) and gives the new value only:
foo_property.add_change_listener {|new| puts "Foo just changed to #{new}" }All classes are augmented with property_accessor, property_reader, and property_writer. These methods function similarly to attr_* functions, except property_* methods get and set the observable value. Note these do not initialize the property. You must do that yourself before you use them.
class FooClass
include JRubyFX
property_accessor :bar
def initialize
@bar = SimpleDoubleProperty.new(this, "bar", 5)
end
end
foo = FooClass.new
foo.bar #=> 5
foo.bar = 6
foo.bar_property.value #=> 6
foo.bar #=> 6TODO: resource_root
TODO:
- fxml_root
- fxml (class)
- Stage#fxml, Stage#fxml=
- load_fxml (instance)
TODO