Forum: JRuby JRubyFX simple EventHandler

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rodrigo B. (Guest)
on 2015-05-11 19:12
(Received via mailing list)
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
​
Thomas E Enebo (Guest)
on 2015-05-11 19:48
(Received via mailing list)
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


On Mon, May 11, 2015 at 10:10 AM, Rodrigo B. <
Rodrigo B. (Guest)
on 2015-05-11 21:15
(Received via mailing list)
Thanks....

2015-05-11 12:47 GMT-03:00 Thomas E Enebo 
<removed_email_address@domain.invalid>:
Rodrigo B. (Guest)
on 2015-05-12 00:01
(Received via mailing list)
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 
<removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.