jruby / jrubyfx Goto Github PK
View Code? Open in Web Editor NEWJavaFX JRuby binding
License: Apache License 2.0
JavaFX JRuby binding
License: Apache License 2.0
I just hacked this for drag_event.rb:
tmc = enum_converter(Java::javafx::scene::input::TransferMode)
converter_for :accept_transfer_modes, &tmc
# FIXME: For non-dsl calls like this we want converter logic
alias :accept_transfer_modes_orig :accept_transfer_modes
def accept_transfer_modes(*values)
accept_transfer_modes_orig *attempt_conversion(self, "accept_transfer_modes", *values)
end
This snippet shows how I worked around being able to:
event.accept_transfer_modes :move
Notice since we are just calling a method on an object our DSL is not firing the converters on the arguments. I was going to just make another method for this but I am wondering whether converter_for should do this logic by default. What do we think?
jit leaves out getters, like styleclass.add(...) and nested properties:
CustomControl > ui > children
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706
on Java HotSpot(TM) Client VM 1.7.0_13-b20 [Windows XP-x86]
(I think..) I've updated to the latest jrubyfx gem version using jruby -S gem install jrubyfx
Now the jrubyfx-jarify command doesn't seem to work anymore:
C:\example>jrubyfx-jarify app\ --main app\main.rb myapp.jar
IOError: Cannot run program "ant.bat" (in directory "C:\example"): CreateProcess error=2, Can't find specified file
popen at org/jruby/RubyIO.java:3964
load_from_ant at c:/jruby-1.7.2/lib/ruby/shared/ant.rb:5
load at c:/jruby-1.7.2/lib/ruby/shared/ant.rb:38
Ant at c:/jruby-1.7.2/lib/ruby/shared/ant.rb:61
(root) at c:/jruby-1.7.2/lib/ruby/shared/ant.rb:3
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9.2-java/lib/jrubyfx_tasks.rb:1
require at org/jruby/RubyKernel.java:1027
(root) at c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9.2-java/lib/jrubyfx_tasks.rb:22
(root) at c:/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:1
load at org/jruby/RubyKernel.java:1046
(root) at c:\jruby-1.7.2\bin\jrubyfx-jarify:23
enable JIT dumping to disk aka AOT fxml compilation
it should be the other way around
@location.text = "blah"
complains that @location does nt have text= method because its a URL when in a controller class
Apparently it happens in Java.
Trying to get past my last bug reported. I loaded jrubyfx 1.0 and now I'm getting unknown property type errors where I wasn't getting them before. The class below TbEntity was successfully used as collection type for a list within a tableview.
Apparently , the error is in the method <fxml_accessor> here:
ptype.java_class.java_instance_methods.find_all{|x|x.name == "getValue"}
i.e. the above returns an empty array.
Again, I was successfully making those calls based on prior git repo source code.
The code says to manually supply a which I didn't have to before. By do we mean Ruby type i.e. in this case a String ?
Stack:
RuntimeError: Unknown property type. Please manually supply a type or report this as a bug
fxml_accessor at /Users/charles/.rvm/gems/jruby-1.7.4/gems/jrubyfx-1.0.0-java/lib/jrubyfx/module.rb:135
TbEntity at /Users/charles/RubymineProjects/TbHolidayMaintenance/src/lib/tb_entity.rb:9
(root) at /Users/charles/RubymineProjects/TbHolidayMaintenance/src/lib/tb_entity.rb:4
require at org/jruby/RubyKernel.java:1054
(root) at file:/Users/charles/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/kernel19/kernel.rb:1
require_relative at file:/Users/charles/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/kernel19/kernel.rb:21
require at org/jruby/RubyKernel.java:1054
(root) at /Users/charles/RubymineProjects/TbHolidayMaintenance/src/lib/holiday_maintenance_controller.rb:5
(root) at file:/Users/charles/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/kernel19/kernel.rb:1
load at org/jruby/RubyKernel.java:1073
(root) at -e:1
Process finished with exit code 1
class TbEntity
include JRubyFX
fxml_accessor :processed_date, java.lang.String
fxml_accessor :entity_type, java.lang.String
fxml_accessor :entity_name, java.lang.String
def initialize date, type , name
converted_date = (DateTime.parse date).strftime('%m/%d/%y')
@processed_date = SimpleStringProperty.new converted_date
@entity_type = SimpleStringProperty.new type
@entity_name = SimpleStringProperty.new name
end
end
TbEntity.become_java!
apparently jrubyfx jdk 8 is still required or checked for although Oracle's JDK and packaging tools already support native packaging i.e. jdk 1.7x certainly 0_25, 0_45
is this a matter of an out of date check still being in place ?
thanks
-Charles
Dear folks,
This looks like it could be a useful project for folks trying to use JavaFX with JRuby for creating desktop GUI's. I'm guessing it's a little like MonkeyBars but for JavaFX rather than for straight Java Swing. However, as I am not a Java guru - and am only really just getting to grips with Ruby (let alone JRuby) it would be nice if the readme.md in this project had slightly more info/help than the Build section does right now.
We easily have enough content in this library to do a gem release. Is there anything sketchy we should fix before putting out a release? Getting a release out would be good to get more people playing with this.
I've installed the gem form today's master from github. Errorlog: https://gist.github.com/friflaj/4960358
I took the demo sample files from the samples/fxml directory and tried running from the command line as per instructions which failed but then set it up an IDEA project with the respective source files. I'm Mac OS X 10.8.3 , Jruby 1.7.3, on Java 1.7, jruby 0.9.2
it fails here:
class ComplexControl < Java::javafx::scene::layout::BorderPane
include JRubyFX::Controller
error:
/Library/Frameworks/JRuby.framework/Versions/Current/bin/jruby --1.9 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/charles/IdeaProjects/jruby/JavaFXDemo/src/demo.rb
TypeError: wrong argument type Class (expected Module)
include at org/jruby/RubyModule.java:2068
ComplexControl at /Users/charles/IdeaProjects/jruby/JavaFXDemo/src/complex_control.rb:4
(root) at /Users/charles/IdeaProjects/jruby/JavaFXDemo/src/complex_control.rb:3
require at org/jruby/RubyKernel.java:1027
require at /Library/Frameworks/JRuby.framework/Versions/1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at file:/Library/Frameworks/JRuby.framework/Versions/1.7.3/lib/jruby.jar!/jruby/kernel19/kernel.rb:1
require_relative at file:/Library/Frameworks/JRuby.framework/Versions/1.7.3/lib/jruby.jar!/jruby/kernel19/kernel.rb:19
load at org/jruby/RubyKernel.java:1046
(root) at -e:1
Process finished with exit code 1
#!/usr/bin/env jruby
require 'jrubyfx'
class MyTask < Java::javafx.concurrent.Task
def call
puts "#{self.class} has been called"
end
end
class MyService < Java::javafx.concurrent.Service
protected
def createTask
MyTask.new
end
end
class MyApp < JRubyFX::Application
def start(stage)
service = MyService.new
# FIXME add a converter for
# service.on_succeeded
service.set_on_succeeded do
puts "done with service"
end
service.start
with(stage, height: 300, width: 300) do
layout_scene do
label(text: "my app")
end
end
stage.show
end
end
MyApp.launch
Forgive me if this is not the section for something more like a feature request than a bug, but I was assuming that .rb files inside jar would have been AOT compiled to java bytecode, instead of being stored as plain ruby scripts.
Or is there something I can do to obtain this before running "jrubyfx-jarify" ?
Thanks
class Java::JavafxSceneControl::ScrollPane
include JRubyFX::DSL
def hbar_policy=(rbenum)
java_send "setHbarPolicy", [Java::JavafxSceneControl::ScrollBarPolicy], JRubyFX::Utils::CommonConverters.parse_ruby_symbols(rbenum, Java::JavafxSceneControl::ScrollBarPolicy)
end
is wrong, Java::JavafxSceneControl::ScrollBarPolicy => Java::JavafxSceneControl::ScrollPane::ScrollBarPolicy
This is opened as a feature request in reponse to #26. I wrote it up as a feature request. When we run jrubyfx-jarify we should allow AOT compilation for partial obfuscation. It is not a ton of obfuscation but it is enough to discourage casual cheating. People will keep asking for this as well, so we might as well do it.
Hi,
Let me start by saying that I am really excited about JRubyFX. I have started working with it and one of the first things I tried (after the Getting Started Guide), was to recreate the FXML example from www.oracle.com. This example uses a <GridPane>
element and I was unable to get it to work. I was getting the following error:
Fragment of fxml file:
<GridPane fx:id="rootGridPane" xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
Exception running Application:
org/jruby/RubyModule.java:2677:in const_missing' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/rrba.rb:405:in
coerce'
/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/rrba.rb:344:in coerce' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/rrba.rb:235:in
[]='
/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:424:in applyProperty' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:284:in
processValue3'
/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:243:in processPropertyAttribute' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:152:in
processInstancePropertyAttributes'
org/jruby/RubyArray.java:1613:in each' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:151:in
processInstancePropertyAttributes'
/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/value_elts.rb:86:in processEndElement' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/jrubyfx-fxmlloader.rb:409:in
processEndElement'
/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/jrubyfx-fxmlloader.rb:205:in load' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-0.9.2-java/lib/jrubyfx/fxml_controller.rb:90:in
load_into'
/home/seanl/personal/NetBeansProjects/JRubyFXDemo3/lib/Hello.rb:6:in start' /home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-0.9.2-java/lib/jrubyfx/java_fx_impl.rb:121:in
launch_app_after_platform'
org/jruby/gen/InterfaceImpl1373357759.gen:13:in `run'
If I remove the alignment attribute, the code works fine.
I noticed that this also occurs for <HBox>
as well. I haven't tried other elements yet.
Thanks,
Sean
following the oracle javafx tutorials , here:
http://docs.oracle.com/javafx/2/ui_controls/table-view.htm
I setup the following code in jruby:
@entity_type_col.setCellFactory(TextFieldTableCell.forTableColumn())
where @entity_type_col is the fxid for a column in a table control
and yes I have the appropriate import statements and I have confirmed via the debugger that I have the appropriate Java entity
I have confirmed that just doing the same in Java i.e. not specifying the setOnEditCommit handler will not cause a crash in Java
unfortunately it does in jrubyfx ie. just setting the the cell factory with the pre-existing Java construct will cause an error, I get the following:
SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: TableRow[id=null, styleClass=cell indexed-cell table-row-cell], name: skinClassName, value: com.sun.javafx.scene.control.skin.TableRowSkin]' for control TableRow[id=null, styleClass=cell indexed-cell table-row-cell]
java.lang.ClassCastException: org.jruby.RubyString cannot be cast to java.lang.String
at javafx.util.converter.DefaultStringConverter.toString(DefaultStringConverter.java:33)
at javafx.scene.control.cell.CellUtils.getItemText(CellUtils.java:94)
at javafx.scene.control.cell.CellUtils.updateItem(CellUtils.java:163)
at javafx.scene.control.cell.TextFieldTableCell.updateItem(TextFieldTableCell.java:200)
at javafx.scene.control.TableCell.updateItem(TableCell.java:549)
at javafx.scene.control.TableCell.indexChanged(TableCell.java:105)
at javafx.scene.control.TableCell$1.invalidated(TableCell.java:93)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
etc ....
Lots of classes are opaque except for oracle documentation. override .inspect
to make it easier to see what is available
During development the usage of the .add_change_listener
method works correctly, however once you try running the jarified version of the program java throws the following error
Exception running Application:
#<TypeError: illegal access on 'addListener': Class org.jruby.javasupport.JavaMethod can not access a member of class javafx.scene.control.TextInputControl$TextProperty with modifiers "public">
org/jruby/java/proxies/JavaProxy.java:347:in `java_send'
reflection is slow, so if we pre-compile all of it, startup time will be faster (tested with old version reveal startup times goes from 15 seconds to 6 second)
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) 64-Bit Server VM 1.8.0-ea-b63 +indy [Windows 7-amd64]
0.9.2 failed
last working commit: 0479602
Yay java8 early access changes. Guess it's time to update.
# See: http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm
require 'jrubyfx'
class MyDoubleBinding < Java::javafx.beans.binding.DoubleBinding
def initialize(a, b, c, d)
@a, @b, @c, @d = a, b, c, d
super
super.bind(@a, @b, @c, @d)
end
java_signature 'protected double computeValue()'
def compute_value
(@a.get * @b.get) + (@c.get * @d.get)
end
end
module LowLevelBindingDemo
import javafx.beans.property.SimpleDoubleProperty
def self.main
a = SimpleDoubleProperty.new(1)
b = SimpleDoubleProperty.new(2)
c = SimpleDoubleProperty.new(3)
d = SimpleDoubleProperty.new(4)
db = MyDoubleBinding.new(a, b, c, d)
puts db.get
b.value = 3
puts db.get
end
end
LowLevelBindingDemo.main
Results on latest jruby(fx) with fxmlloader in
% jruby low_level_binding_demo.rb
ArgumentError: wrong number of arguments for constructor
initialize at low_level_binding_demo.rb:7
main at low_level_binding_demo.rb:26
(root) at low_level_binding_demo.rb:33
I tried several version, but I cannot remove this error. The call to super has now parameters like the JavaFX suggests. Any suggestions what is wrong with the above code?
Can someone help me to get this: http://stackoverflow.com/questions/11242847/is-drag-and-drop-supported-by-treeitem implemented using jrubyFX? I've got the tree working, which was simple, but the drag and drop bits use a callback mechanism which I'm not sure how to translate into jrubyfx.
This is all about supporting 2.0 lang level in 1.7.4 including debug support. JetBrains just released a patch i.e. ruby-debug-base 0.10.5.rc5 which allows debug in 2.0 mode, however the issue is with: ruby-debug-ide 0.4.18 which has been available in RubyMine for a bit.
If you don't require jrubyfx , this all works i.e. on top of the jruby 1.7.4 sdk
Please see gist: https://gist.github.com/amiracam/6126346
So after the earlier issue, wanting to test the packaging tools on Windows, and finally getting the jarify command working in spite of my Windows ignorance, I went to run the jar and it wouldn't run. So I tried just running the the source, the samples, they all kept getting the above error, which indicates-- for those who may find this when searching later-- that the jfxrt.jar isn't on the classpath.
I tried all manner of methods to get this working, uninstalling jdk8 and installing jdk7, changing java_home, setting classpath from the command line, trying the java installed in different places "ProgramFiles", "C:", "User/Me", I even used a Maven plugin which is supposed to fix issues with JavaFX, Windows and the classpath, that I'd read about a short while ago.
Still kept getting the below error:
LoadError: no such file to load -- jfxrt
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:
36
(root) at c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9-java/
lib/jrubyfx/jfx_imports.rb:27
require at org/jruby/RubyKernel.java:1027
(root) at c:/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:
1
require at c:/jruby-1.7.2/lib/ruby/shared/rubygems/custom_require.rb:
36
require_relative at file:/C:/jruby-1.7.2/lib/jruby.jar!/jruby/kernel19/kernel.
rb:19
require at org/jruby/RubyKernel.java:1027
(root) at c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9-java/
lib/jrubyfx.rb:21
(root) at HelloWorldApp.rb:1
Finally, found in jrubyfx / lib / jrubyfx / jfx_imports.rb where it would check for an environmental variable called "JFX_DIR", so once I set that everything began to work as expected so far.
I've VERY possibly missed something simple that would have solved this, but figured it was also likely either no one was using windows or they were using IDE's which were managing this. Sorry so long-winded, wanted to make sure to point out what did not work, though.
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
totally skips styleClass
I program a bit on JavaFX for my GSoC project in jrubyfx. The form view example
http://docs.oracle.com/javafx/2/get_started/form.htm#BABHABBF
looks like this in jrubyfx
https://gist.github.com/komax/5933828
Everything works, except the set_on_action call back (with just puts, it works). On my linux mint 14 with oracle jdk7 and jruby master, I get this error:
% jruby form_javafx.rb
Exception in thread "JavaFX Application Thread" org.jruby.exceptions.RaiseException: (NameError) undefined local variable or method `actiongarget' for #<FormApp:0x7dc0e904>
at org.jruby.RubyBasicObject.method_missing(org/jruby/RubyBasicObject.java:1497)
at RUBY.method_missing(/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx/dsl.rb:86)
at form_javafx.start(form_javafx.rb:48)
at org.jruby.gen.InterfaceImpl791640704.handle(org/jruby/gen/InterfaceImpl791640704.gen:13)
jruby form_javafx.rb 12,33s user 0,31s system 126% cpu 9,967 total
> jfxObject.enum_prop = :enum_value
> jfxObject.enum_prop == :enum_value
false
> jfxObject.enum_prop == EnumType::EnumValue
true
This is the current behavior pattern of enums. We need to override comparisons so that it meets expectations. This can probbably go with the enum injection code in dsl.rb. Annoys me the most often with KeyCodes
When I tried to creating jar with sample source, I got following error.
โฏ jruby -S jrubyfx-jarify samples/fxml/ --main samples/fxml/Demo.rb Demo.jar
mkdir -p /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6
cp /Users/momonga/.jruby-jar/jruby-complete.jar /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6/Demo.jar
cp samples/fxml//complex_control.rb /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6/complex_control.rb
cp samples/fxml//ComplexControl.fxml /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6/ComplexControl.fxml
cp samples/fxml//Demo.fxml /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6/Demo.fxml
cp samples/fxml//Demo.rb /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6/Demo.rb
cp samples/fxml/Demo.rb /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6/jar-bootstrap.rb
cp -r /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6
cp -r /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx.rb /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6
cp -r /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx_tasks.rb /var/folders/jf/9wcyvc712dgbrnx19dxlrfy80000gn/T/jrubyfx20130810-36785-1mgv3p6
NoMethodError: undefined method `add_method_signature' for StupidFixTODOInsets:Class
StupidFixTODOInsets at /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/fxmlloader/value_elts.rb:7
(root) at /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/fxmlloader/value_elts.rb:3
require at org/jruby/RubyKernel.java:1054
require at /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at file:/usr/local/Cellar/jruby/1.7.4/libexec/lib/jruby.jar!/jruby/kernel19/kernel.rb:1
require_relative at file:/usr/local/Cellar/jruby/1.7.4/libexec/lib/jruby.jar!/jruby/kernel19/kernel.rb:21
require at org/jruby/RubyKernel.java:1054
require at /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/jrubyfx-fxmlloader.rb:702
(root) at /usr/local/Cellar/jruby/1.7.4/libexec/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx_tasks.rb:1
load at org/jruby/RubyKernel.java:1073
(root) at /usr/local/Cellar/jruby/1.7.4/libexec/bin/jrubyfx-jarify:23
My environment is here, and I'm using Mac OS X Mountain Lion.
โฏ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
โฏ echo $CLASSPATH
.:/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre/lib/jfxrt.jar
โฏ jruby -v
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_25-b15 [darwin-x86_64]
โฏ jruby -S gem -v
1.8.24
โฏ jruby -S gem list
*** LOCAL GEMS ***
jrubyfx (1.0.0 java)
jrubyfx-fxmlloader (0.2 java)
rake (10.1.0, 10.0.3)
Demo.rb
is works perfectly with direct launching with jruby command.
โฏ jruby -S samples/fxml/Demo.rb
so my app which opened under jruby 1.7.4 and JDK 1.7.0.45 crashed when I try to open it with either jruby 1.7.4 or 1.7.6 under JDK 1.8
btw, my understanding is that JDK 1.8 comes JavaFX ready
jruby 1.7.6 (1.9.3p392) 2013-10-23 6004147 on Java HotSpot(TM) 64-Bit Server VM 1.8.0-ea-b112 +indy [darwin-x86_64]
stack:
NameError: cannot initialize Java class javafx.scene.control.Pagination
(root) at /Users/charles/.rvm/gems/jruby-1.7.6/gems/jrubyfx-1.1.0-java/lib/jrubyfx/core_ext/pagination.rb:20
require at org/jruby/RubyKernel.java:1082
(root) at /Users/charles/.rvm/rubies/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at /Users/charles/.rvm/rubies/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
glob at org/jruby/RubyDir.java:339
load_dsl at /Users/charles/.rvm/gems/jruby-1.7.6/gems/jrubyfx-1.1.0-java/lib/jrubyfx/dsl.rb:313
load_dsl at /Users/charles/.rvm/gems/jruby-1.7.6/gems/jrubyfx-1.1.0-java/lib/jrubyfx/dsl.rb:312
require at org/jruby/RubyKernel.java:1082
(root) at /Users/charles/.rvm/gems/jruby-1.7.6/gems/jrubyfx-1.1.0-java/lib/jrubyfx.rb:37
(root) at amn_main_ui.rb:3
Using http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html on Ubuntu 12.04 64 Bit, master jrubyfx and fxmlloader master I get this error:
% jruby main.rb
Exception running Application:
#<NoMethodError: undefined method `lastIndexOf' for "http://javafx.com/javafx/2.2":String>
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/fxmlloader/value_elts.rb:153:in `processValue'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/fxmlloader/value_elts.rb:69:in `processStartElement'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/jrubyfx-fxmlloader.rb:292:in `processStartElement'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-fxmlloader-0.2-java/lib/jrubyfx-fxmlloader.rb:212:in `load'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx/controller.rb:99:in `load_into'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx/core_ext/stage.rb:82:in `fxml'
main.rb:8:in `start'
org/jruby/RubyBasicObject.java:1536:in `instance_eval'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx/module.rb:48:in `with'
main.rb:7:in `start'
/home/max/Programmierung/gsoc/jruby/lib/ruby/gems/shared/gems/jrubyfx-1.0.0-java/lib/jrubyfx/java_fx_impl.rb:120:in `launch_app_after_platform'
org/jruby/gen/InterfaceImpl1016166966.gen:13:in `run'
jruby main.rb 25,48s user 0,50s system 231% cpu 11,215 total
It looks like the fxmlloader has problems with these namespaces
xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"
With
xmlns:fx="http://javafx.com/fxml"
it works correctly.
Compare
jruby/jruby-visualizer@bf959d3#lib/ui/jruby-visualizer.fxml
the java_includes require lots of unnecessary startup time for most cases. Make it lazy
When you call a color converter (just an example) which takes a symbol we get a rather weird error message to anyone who is not a JRubyFX hacker:
Exception running Application:
#<TypeError: cannot convert instance of class org.jruby.RubySymbol to class javafx.scene.paint.Paint>
/Users/enebo/work/jrubyfx/lib/jrubyfx/core_ext/precompiled.rb:908:in `fill='
Now we know something went wrong with fill= but this is pretty confusing to new users and we can give better feed back. Here is what I have a patch for (I will commit it as a discussion provoker):
Exception running Application:
#<ArgumentError: No such color: redbull>
/Users/enebo/work/jrubyfx/lib/jrubyfx/utils/common_converters.rb:144:in `CommonConverters'
org/jruby/RubyProc.java:264:in `call'
/Users/enebo/work/jrubyfx/lib/jrubyfx/core_ext/precompiled.rb:908:in `fill='
So the backtrace now shows common converters and the proc call for the converter but the message is likely to be really obvious. It would be possible to make a much more sophisticated coercion mechanism but I feel this is a big improvement for a tiny amount of work.
This may not be the right place for this, but yeah, figured out the webstart thing. There's not really a good way to automate it on our end, as far as I can tell, because it requires signing the jar, but anyways here's my blog post about it:
Hi,
I am trying to use the Table View with JRubyFX. I am using the latest version (not the 0.9.2) series because I also want to help and report issues as I find them.
Below is the section of the FXML file that implements the table view (and my FXML file is based on the example for Table Views in the Oracle JavaFX documentation):
<TableView fx:id="table_stock_data" prefHeight="260.0" prefWidth="390.0">
<columns>
<TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="315.0" text="Stock">
<cellValueFactory>
<PropertyValueFactory property="symbol" />
</cellValueFactory>
</TableColumn>
<TableColumn prefWidth="75.0" text="Shares">
<cellValueFactory>
<PropertyValueFactory property="shares" />
</cellValueFactory>
</TableColumn>
</columns>
<items>
<FXCollections fx:factory="observableArrayList">
</FXCollections>
</items>
</TableView>
I get the following error:
Exception in runnable
org.jruby.exceptions.RaiseException: (LoadException) Class sun.reflect.misc.ReflectUtil can not access a member of class javafx.collections.FXCollections with modifiers "private"
at RUBY.constructValue(/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/real_elts.rb:96)
at RUBY.processStartElement(/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/value_elts.rb:64)
at RUBY.processStartElement(/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/jrubyfx-fxmlloader.rb:282)
at RUBY.load(/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-fxmlloader-0.0.1/lib/jrubyfx-fxmlloader.rb:202)
at RUBY.load_into(/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-0.9.2-java/lib/jrubyfx/fxml_controller.rb:90)
at home.seanl.personal.NetBeansProjects.StockMaster.lib.gui_test.start(/home/seanl/personal/NetBeansProjects/StockMaster/lib/gui_test.rb:25)
at RUBY.launch_app_after_platform(/home/seanl/.rvm/gems/jruby-1.7.3/gems/jrubyfx-0.9.2-java/lib/jrubyfx/java_fx_impl.rb:121)
at org.jruby.gen.InterfaceImpl499724206.run(org/jruby/gen/InterfaceImpl499724206.gen:13)
Removing the <FXCollections></FXCollections>
section solves this problem, but of course I cannot then get data into the table.
I have actually forked this project and JRubyFX_FXMLLoader, but I don't know that my programming skills are strong enough to be able to help. I would like to help with documentation though. I am really excited about JRubyFX as I feel that it is the PERFECT solution for me, and I really want to see it succeed, which is why I would like to help in any way I can.
When you construct your own classes you want to be able to make those classes fit into and feel like the main DSL. We already had an unused register_type method for this purpose but I am changing it a little bit:
register_type(type, name=nil)
So when with this in place I can:
class MultiTouchPane < Java::javafx::scene::layout::Region
register_type self
end
and then use it in my dsl:
layout_scene(400, 400, :black) do
group do
multi_touch_pane(image)
end
end
So, I've been doing some experiments the past few days trying to figure out the webstart stuff, and in doing so hit upon a weird bug. If I have a jruby-complete.jar with jrubyfx copied in, I can certainly run jrubyfx apps with it like:
java -jar jruby-complete.jar hello.rb
and it works like a charm. But given the same jar, let's say I have this ruby class:
require "jrubyfx"
class Hello < JRubyFX::Application
def start(stage)
with(stage, title: "Hello JRuby", x: 105, y: 140) do
stage.layout_scene(500, 250, :black) do
hbox(padding: insets(60)) do
text('JRuby', font: font('sanserif', 80)) do
fill linear_gradient(0,0,0,1, true, :no_cycle, [stop(0, :pale_green), stop(1, :sea_green)])
end
text('FX', font: font('sanserif', 80)) do
fill linear_gradient(0,0,0,1, true, :no_cycle, [stop(0, :cyan), stop(1, :dodger_blue)])
set_effect(drop_shadow(color: :dodger_blue, radius: 25,spread: 0.25))
end
end
end
show
end
end
end
Hello.launch
And try to call it from a launcher like this:
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.concurrent.Task;
import org.jruby.embed.ScriptingContainer;
public class Launcher extends Application {
public static void main(final String[] args) {
Application.launch(args);
}
public void start(final Stage stage) throws Exception
{
Task task = new Task<Void>()
{
@Override
protected Void call() throws Exception
{
ScriptingContainer container = new ScriptingContainer();
container.runScriptlet("require 'hello.rb'");
return null;
}
};
new Thread(task).start();
}
}
Then I get the following error:
Exception running Application:
#<NoMethodError: undefined method `layout_scene' for #<Java::JavafxStage::Stage:0x7f243900>>
/home/eric/projects/jrubyfx_projects/jrubyfx_web/hello.rb:7:in `start'
org/jruby/RubyBasicObject.java:1691:in `instance_eval'
jar:file:/home/eric/projects/jrubyfx_projects/jrubyfx_web/jruby-complete.jar!/jrubyfx/fxml_module.rb:49:in `with'
/home/eric/projects/jrubyfx_projects/jrubyfx_web/hello.rb:6:in `start'
jar:file:/home/eric/projects/jrubyfx_projects/jrubyfx_web/jruby-complete.jar!/jrubyfx/java_fx_impl.rb:121:in `launch_app_after_platform'
org/jruby/gen/InterfaceImpl1339899994.gen:13:in `run'
Ignore that I'm probably doing all sorts of horrible things with this code, since it's just experimental, but for whatever reason, in this situation, layout_scene
(and perhaps other parts of the DSL, I don't know yet) vanish. The very same java launcher is perfectly capable of launching other far more complex JRubyFX apps, that use FXML and CSS, but toss in layout_scene
and it breaks down. Just thought I'd get this in while it was fresh in mind. Thanks. Seems like at some point, scripting existing javafx apps with jrubyfx might be an interesting use case, so thought it would be worth mentioning that this happens.
(Still haven't gotten webstart/jnlp working, but I think I'm starting to get useful errors finally so that's always a good sign).
The build is failing for me on Mac OS X 10.8.2 (Mountain Lion). I'm not sure why. I use RVM with jruby and Java with JavaFX bundled in.
Here's some of my env variables:
MY_RUBY_HOME=/Users/stemblej/.rvm/rubies/jruby-head
JRUBY_HOME=/Users/stemblej/.rvm/rubies/jruby-head
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home
rvm_ruby_string=jruby-head
RUBY_VERSION=jruby-head
jruby version:
jruby 1.7.0.preview2 (1.9.3p203) 2012-08-16 86231f6 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_06-b24 [darwin-x86_64]
Here's the error:
Buildfile: /Users/stemblej/Downloads/jrubyfx-master/build.xml
detect.javafx:
setup.bundled.path:
[echo] Running Java 7 with JavaFx bundled...adding jar
setup.integrated.path:
setup.external.path:
setup.path:
init:
build:
[javac] Compiling 1 source file to /Users/stemblej/Downloads/jrubyfx-master/target/classes
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:5: error: package org.jruby.javasupport does not exist
[javac] import org.jruby.javasupport.Java;
[javac] ^
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:6: error: package org.jruby.javasupport does not exist
[javac] import org.jruby.javasupport.JavaObject;
[javac] ^
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:7: error: package org.jruby.runtime does not exist
[javac] import org.jruby.runtime.ThreadContext;
[javac] ^
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:8: error: package org.jruby.runtime.builtin does not exist
[javac] import org.jruby.runtime.builtin.IRubyObject;
[javac] ^
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:11: error: cannot find symbol
[javac] public static IRubyObject handler;
[javac] ^
[javac] symbol: class IRubyObject
[javac] location: class JRubyFX
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:13: error: cannot find symbol
[javac] public static void start(IRubyObject obj) {
[javac] ^
[javac] symbol: class IRubyObject
[javac] location: class JRubyFX
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:39: error: cannot find symbol
[javac] private ThreadContext ctx() {
[javac] ^
[javac] symbol: class ThreadContext
[javac] location: class JRubyFX
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:13: error: start(IRubyObject) in JRubyFX cannot override start(Stage) in Application
[javac] public static void start(IRubyObject obj) {
[javac] ^
[javac] overriding method is static
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:28: error: cannot find symbol
[javac] IRubyObject[] args = new IRubyObject[] {
[javac] ^
[javac] symbol: class IRubyObject
[javac] location: class JRubyFX
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:28: error: cannot find symbol
[javac] IRubyObject[] args = new IRubyObject[] {
[javac] ^
[javac] symbol: class IRubyObject
[javac] location: class JRubyFX
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:29: error: cannot find symbol
[javac] Java.wrap(ctx().runtime, JavaObject.wrap(ctx().runtime, primaryStage))
[javac] ^
[javac] symbol: variable JavaObject
[javac] location: class JRubyFX
[javac] /Users/stemblej/Downloads/jrubyfx-master/src/org/jruby/ext/jrubyfx/JRubyFX.java:29: error: cannot find symbol
[javac] Java.wrap(ctx().runtime, JavaObject.wrap(ctx().runtime, primaryStage))
[javac] ^
[javac] symbol: variable Java
[javac] location: class JRubyFX
[javac] 12 errors
BUILD FAILED
/Users/stemblej/Downloads/jrubyfx-master/build.xml:68: Compile failed; see the compiler error output for details.
Total time: 0 seconds
I got the "rake jar" task to run by cd'ing into my clone of the jrubyfx repo, and running it like:
jruby -S rake jar main_script=~/projects/jrubyfx_projects/Hello/src/hello2.rb
This properly built the jar for me, except it doesn't seem to include my fxml file. My hello2.rb file looks like:
require "jrubyfx"
class HelloWorldApp < JRubyFX::Application
def start(stage)
with(stage, title: "Hello World!", width: 800, height: 600)
HelloWorldController.load_fxml("Hello.fxml", stage)
stage.show()
end
end
class HelloWorldController < JRubyFX::Controller
fx_id :helloLabel
fx_handler :sayClicked do
@helloLabel.text = "You clicked me!"
end
end
HelloWorldApp.launch
And trying to run the jar gives this error:
Exception running Application:
java.lang.IllegalStateException: Location is not set.
javafx.fxml.FXMLLoader.load(FXMLLoader.java:2021)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440)
org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:304)
org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:52)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136)
org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:64)
org.jruby.ast.ReturnNode.interpret(ReturnNode.java:92)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:268)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:220)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:366)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:238)
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:225)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
classpath_3a_jar_minus_bootstrap.method__1$RUBY$start(classpath:jar-bootstrap.rb:6)
classpath_3a_jar_minus_bootstrap$method__1$RUBY$start.call(classpath_3a_jar_minus_bootstrap$method__1$RUBY$start)
classpath_3a_jar_minus_bootstrap$method__1$RUBY$start.call(classpath_3a_jar_minus_bootstrap$method__1$RUBY$start)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:224)
org.jruby.ast.RescueNode.interpret(RescueNode.java:119)
org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:209)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:197)
org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:128)
org.jruby.runtime.Block.call(Block.java:89)
org.jruby.RubyProc.call(RubyProc.java:261)
org.jruby.RubyProc.call(RubyProc.java:213)
org.jruby.javasupport.JavaUtil$1.call(JavaUtil.java:237)
org.jruby.javasupport.util.RuntimeHelpers$MethodMissingMethod.call(RuntimeHelpers.java:473)
org.jruby.gen.InterfaceImpl1921571541.run(org/jruby/gen/InterfaceImpl1921571541.gen:13)
com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
java.lang.Thread.run(Thread.java:722)
#
# A fatal error has been detected by the Java Runtime Environment:
And as far as I can tell, from opening up the jar, this is because the fxml file didn't seem to get included in it.
# See: http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm
require 'jrubyfx'
class Bill
import javafx.beans.property.SimpleDoubleProperty
def initialize
@amount_due = SimpleDoubleProperty.new
end
def amount_due
@amount_due.get
end
def amount_due=(value)
@amount_due.set(value)
end
def amount_due_prop
@amount_due
end
end
def main
electric_bill = Bill.new
electric_bill.amount_due_prop.add_listener do |obj, old_val, new_val|
puts "Electric bill has changed!"
end
electric_bill.amount_due = 100.0
bill1, bill2, bill3 = Bill.new, Bill.new, Bill.new
total = Java::javafx.beans.binding.Bindings.add(bill1.amount_due_prop.add(
bill2.amount_due_prop), bill3.amount_due_prop)
total.add_listener do |observable|
puts "The binding is now invalid"
end
# First call makes the binding invalid
bill1.amount_due = 200.0
# The binding is now invalid
bill2.amount_due = 100.0
bill3.amount_due = 75.0
# Make the binding valid
puts total.value
# Make invalid...
bill3.amount_due = 150.0
# Make valid
puts total.value
end
main
on latest jruby, jrubyfx and fxmlloader creates these warnings:
jruby property_demo.rb
property_demo.rb:27 warning: ambiguous Java methods found, using addListener(javafx.beans.InvalidationListener)
Electric bill has changed!
property_demo.rb:36 warning: ambiguous Java methods found, using addListener(javafx.beans.InvalidationListener)
The binding is now invalid
375.0
The binding is now invalid
450.0
Or may I use another way for High Level Binding in jrubyfx?
I created an fxml file that used split panes , basically a left nav pane holding a liar and on the right a top and bottom panes both holding tables. A header section containing labels and a basic user login pane.
I would attach the fxml in question but I don't see how to do that here, other than to copy it to the bottom of this issue.
Here's the error stack:
monteiro:lib charles$ jruby -S schema_browser_application.rb
[converter for Java::JavafxSceneLayout::ColumnConstraints, new]
[converter for Java::JavafxSceneLayout::RowConstraints, new]
[converter for Java::JavafxSceneInput::DragEvent, accept_transfer_modes]
[converter for Java::JavafxSceneEffect::DropShadow, color]
[converter for #Class:Java::JavafxSceneEffect::DropShadow, new]
[converter for Java::JavafxSceneImage::ImageView, viewport]
[converter for Java::JavafxSceneMedia::MediaPlayer, cycle_count]
[converter for Java::JavafxSceneControl::Pagination, page_count]
[converter for Java::JavafxSceneControl::Pagination, new]
[converter for Java::JavafxSceneControl::ProgressIndicator, progress]
[converter for Java::JavafxSceneControl::ProgressIndicator, new]
[converter for Java::JavafxSceneControl::ProgressBar, progress]
[converter for Java::JavafxSceneControl::ProgressBar, new]
[converter for #Class:Java::JavafxScenePaint::RadialGradient, new]
[converter for #Class:Java::JavafxScenePaint::LinearGradient, new]
[converter for Java::JavafxSceneLayout::Region, min_width]
[converter for Java::JavafxSceneLayout::Region, min_height]
[converter for Java::JavafxSceneLayout::Region, pref_width]
[converter for Java::JavafxSceneLayout::Region, pref_height]
[converter for Java::JavafxSceneLayout::Region, max_width]
[converter for Java::JavafxSceneLayout::Region, max_height]
[converter for Java::JavafxSceneLayout::Region, padding]
[converter for Java::JavafxSceneTransform::Rotate, axis]
[converter for #Class:Java::JavafxSceneTransform::Rotate, new]
[converter for Java::JavafxSceneControl::TableView, column_resize_policy]
[converter for Java::JavafxAnimation::Timeline, cycle_count]
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/real_elts.rb:62 warning: singleton on non-persistent Java type Java::JavafxFxml::ObjectBuilder (http://wiki.jruby.org/Persistence)
Exception running Application:
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/rrba.rb:400:in coerce' /Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/rrba.rb:344:in
coerce'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/rrba.rb:235:in []=' /Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:424:in
applyProperty'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:284:in processValue3' /Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:243:in
processPropertyAttribute'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:152:in processInstancePropertyAttributes' org/jruby/RubyArray.java:1613:in
each'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/elts.rb:151:in processInstancePropertyAttributes' /Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/fxmlloader/value_elts.rb:86:in
processEndElement'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/jrubyfx-fxmlloader.rb:409:in processEndElement' /Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-fxmlloader-0.0.1/lib/jrubyfx-fxmlloader.rb:205:in
load'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-0.9.2-java/lib/jrubyfx/fxml_controller.rb:89:in load_into' schema_browser_application.rb:13:in
start'
/Users/charles/.rvm/gems/ruby-1.9.3-p0/gems/jrubyfx-0.9.2-java/lib/jrubyfx/java_fx_impl.rb:121:in launch_app_after_platform' org/jruby/gen/InterfaceImpl1875744039.gen:13:in
run'
monteiro:lib charles$
here's the fxml in question:
I have the following errors when launching "jruby hello_jrubyfx.rb" on windows xp sp3 using Java(TM) SE Runtime Environment (build 1.7.0_13-b20) and jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) Client VM 1.7.0-b147 [Windows XP-x86], with jrubyfx installed with: jgem install jrubyfx
Exception starting app:
java.lang.RuntimeException: java.lang.UnsatisfiedLinkError
["com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:281)", "com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:124)", "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)", "sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)", "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)", "java.lang.reflect.Method.invoke(Method.java:601)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHand
ling(JavaMethod.java:455)", "org.jruby.javasupport.JavaMethod.invokeStaticDirect(JavaMethod.java:367)", "org.jruby.java.invokers.StaticMethodInvoker.call(StaticMethodInvoker.java:110)", "org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(Caching
CallSite.java:316)", "org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:145)", "org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:154)", "org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:64)", "org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)", "org.jruby.ast.BlockNode.interpret(BlockNode.java:71)",
"org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)", "org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)", "org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:188)", "
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)", "org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)", "org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)", "org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)", "org.jruby.ast.RescueNode.executeBody(RescueNode.java:224)", "org.jruby.ast.RescueNode.interpret(RescueNode.java:119)", "org.jruby.ast.BeginNode.interpret(BeginNode.java:83)", "org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)", "org.jruby.ast.BlockNode.interpret(BlockNode.java:71)", "org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)", "org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:209)", "org.
jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:197)", "org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:128)", "org.jruby.runtime.Block.call(Block.java:89)", "org.jruby.RubyProc.call(RubyProc.java:261)", "org.jruby.RubyProc.call(RubyProc.java:213)", "org.jruby.javasupport.JavaUtil$1.call(JavaUtil.java:237)", "org.jruby.javasupport.util.RuntimeHelpers$MethodMissingMethod.call(RuntimeHelpers.java:445)", "org.jruby.gen.InterfaceImpl1595481548.run(org/jruby/gen/InterfaceImpl1595481548.gen:13)", "java.lang.Thread.run(Thread.java:722)"]
I got to this after setting JFX_DIR env. variable to C:\Programmi\Java\jre7\lib because jrubyfx complained that I had an old version of Java or I had JFX_DIR var not set...
Is there anything wrong with my setup?
the Datamapper "finalize" instigated error in the gist below I encountered in the context of jrubufx i.e. upon launching a UI I try to setup a Datamapper db if not already present. I can certainly create Datamapper dbs otherwise in Jruby .This seems to be a low level issue but I have not experienced it in Jruby itself so I thought I ask before digging further. The stack can be found here:
https://gist.github.com/amiracam/6055902
Apparently, the issue is in the instantiation of the class Set
jruby -v:
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) Client VM 1.7.0_13-b20 [Windows XP-x86]
I am having issues with jrubyfx-jarify command.
I created "example" folder in "C:" and I made a subfolder in it called "app".
Inside of "app" I have my_script.rb and Ui.fxml.
Then I try running this from "C:\example"
jrubyfx-jarify app\ --main app\script.rb myapp.jar
which outputs:
mkdir -p C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy
cp C:\Documents and Settings\JJ/.jruby-jar/jruby-complete.jar C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy/myapp.jar
cp app/my_script.rb C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy/my_script.rb
cp app/Ui.fxml C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy/Ui.fxml
cp app\my_script.rb C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy/jar-bootstrap.rb
cp -r c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9.1-java/lib/jrubyfx C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy
cp -r c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9.1-java/lib/jrubyfx.rb C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy
cp -r c:/jruby-1.7.2/lib/ruby/gems/shared/gems/jrubyfx-0.9.1-java/lib/jrubyfx_tasks.rb C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy
cd C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy
jar ufe 'myapp.jar' org.jruby.JarBootstrapMain *
chmod 775 myapp.jar
cd C:/example
mv C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy/myapp.jar myapp.jar
rm -rf C:/DOCUME1/JJ/IMPOST1/Temp/jrubyfx20130207-3036-1vhjwhy
which seems correct, but then when I run java -jar myapp.jar from "C:\example" I get this:
Errno::ENOENT: No such file or directory - No such directory: file:C:/example/myapp.jar!/jrubyfx/core_ext/
initialize at org/jruby/RubyDir.java:149
foreach at org/jruby/RubyDir.java:527
load_dsl at file:C:/example/myapp.jar!/jrubyfx/dsl.rb:210
(root) at file:/C:/example/myapp.jar!/jrubyfx.rb:24
require at org/jruby/RubyKernel.java:1027
(root) at jar:file:/C:/example/myapp.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
(root) at classpath:jar-bootstrap.rb:4
What's going wrong here?
Hope you can help, thanks.
So running the jrubyfx-generator gives this very weird error on Windows when it tries to launch the app after generating the ruby code:
C:\Users\edub\projects\jrubyfx\HelloFXML\src> jrubyfx-generator hello.fxml hello
.rb HelloFXML
Generating JRubyFX template for hello.fxml into hello.rb... Done!
Launching 'jruby hello.rb' ...
Exception running Application:
java.net.MalformedURLException: unknown protocol: c
java.net.URL.<init>(URL.java:589)
java.net.URL.<init>(URL.java:479)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI
mpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA
ccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:399)
org.jruby.javasupport.JavaConstructor.newInstanceDirect(JavaConstructor.java:291
)
org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:104)
org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:197)
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:211)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217)
org.jruby.java.proxies.ConcreteJavaProxy$2.call(ConcreteJavaProxy.java:56)
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:211)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217)
org.jruby.RubyClass.newInstance(RubyClass.java:862)
org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.g
en)
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrNBlock.c
all(JavaMethod.java:295)
org.jruby.java.proxies.ConcreteJavaProxy$3.call(ConcreteJavaProxy.java:155)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346
)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.IfNode.interpret(IfNode.java:118)
org.jruby.ast.AttrAssignOneArgNode.interpret(AttrAssignOneArgNode.java:33)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java
:268)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:220)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:366
)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:238)
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java
:225)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346
)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java
:182)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:188)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326
)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:224)
org.jruby.ast.RescueNode.interpret(RescueNode.java:119)
org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:209)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:197)
org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:128)
org.jruby.runtime.Block.call(Block.java:89)
org.jruby.RubyProc.call(RubyProc.java:261)
org.jruby.RubyProc.call(RubyProc.java:213)
org.jruby.javasupport.JavaUtil$1.call(JavaUtil.java:237)
org.jruby.javasupport.util.RuntimeHelpers$MethodMissingMethod.call(RuntimeHelper
s.java:445)
org.jruby.gen.InterfaceImpl1213658385.run(org/jruby/gen/InterfaceImpl1213658385.
gen:13)
com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:208)
com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:174)
com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
java.lang.Thread.run(Thread.java:722)
It generates the code fine, and the resulting ruby script can be run directly with jruby without error! I've tried using both jrubyfx-generator directly, as in the above error, and using the .bat file. Was fixing a problem with my plugin and then discovered this underneath. Pushing PR that checks for Windows and just doesn't launch the generated app if it is.
Let's say I have a code snippet like:
set_clip rectangle(smooth: true)
If this is executed in a class which can contain children it will add the rectangle as a child and then blow up when trying to set that same rectangle as the clip region. I propose we extend our DSL api so that:
set_clip rectangle!(smooth: true)
By specifying the '!' we are saying we acknowledge it is our responsibliity to deal with the rectangle and that the DSL should not bother to add it for us. Any comments on this? I feel like this is part of the devils bargain for having a nice DSL syntax. I definitely do not want to make adds explicit again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.