[jruby-user] JRubyFX simple EventHandler

21 views
Skip to first unread message

Rodrigo Botafogo

unread,
May 11, 2015, 11:11:52 AM5/11/15
to us...@jruby.codehaus.org

Hello…

I´m trying to write a very simple JRubyFX application with an EventHandler.
My code now:

require 'jrubyfx'

class HelloWorldApp < JRubyFX::Application

  def start(stage)

    with(stage, title: "Hello World!", width: 800, height: 600) do
      layout_scene do
        button("Click me")
        # button.setOnAction(new Bt_Action)
      end
    end

    stage.show # Tip: most of the time, () can be removed from method calls

  end

end

Is it possible to write a button.setOnAction without writing a FXML file?


Thanks

--
Rodrigo Botafogo



Thomas E Enebo

unread,
May 11, 2015, 11:47:58 AM5/11/15
to jruby-user
require 'jrubyfx'

class HelloWorldApp < JRubyFX::Application
  def start(stage)
    with(stage, title: "Hello World!", width: 800, height: 600) do
      layout_scene do
        button("Click me") do
          set_on_action { |e|  puts "PRESSED" }
        end
      end
    end.show
  end
end

HelloWorldApp.launch

--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: tom....@gmail.com

Rodrigo Botafogo

unread,
May 11, 2015, 1:15:13 PM5/11/15
to us...@jruby.codehaus.org
Thanks....
--
Rodrigo Botafogo



Rodrigo Botafogo

unread,
May 11, 2015, 4:00:14 PM5/11/15
to us...@jruby.codehaus.org
One more simple question... in this code, how do I add a Layout Panel to it?

Thanx...

2015-05-11 12:47 GMT-03:00 Thomas E Enebo <tom....@gmail.com>:



--
Rodrigo Botafogo



Reply all
Reply to author
Forward
0 new messages