Hello there,
I know, nobody likes them, but anyway I want to write a applet
Here’s my problem:
I fail to simply add something to the main panel using ruby.
So In Java, this works:
import java.applet.Applet;
import java.awt.Button;
public class NewApplet extends Applet {
/**
* Initialization method that will be called after the applet is
loaded
* into the browser.
*/
public void init() {
add(new Button());
}
}
In ruby i tried:
require ‘java’
import ‘java.awt.Button’
$b=Button.new(“jeha”)
JRUBY_APPLET.on_start{
JRUBY_APPLET.add($b)
}
which produces:
java.lang.RuntimeException: Ruby callback failed
at org.jruby.JRubyApplet.invokeCallback(JRubyApplet.java:256)
at org.jruby.JRubyApplet.start(JRubyApplet.java:282)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.jruby.exceptions.RaiseException: undefined method `add’
for
#Java::OrgJruby::JRubyApplet:0xae97c4
at Kernel.add(/H:/ruby/jruby-1.6.1/lib/test.rb:5)
at (unknown).(unknown)(:1)
at (unknown).(unknown)(:1)
I’m on Windows (I tried the same on (K)Ubuntu and get a different error:
Something,something about Java:lang when importing ‘java.awt.Button’,
but
don’t bother)
I can’t figure it out, can somebody help me out please?
Kind regards,
Peter