JRubyFX simple EventHandler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JRubyFX simple EventHandler

Rodrigo Botafogo

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



Reply | Threaded
Open this post in threaded view
|

Re: JRubyFX simple EventHandler

Thomas E Enebo
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 Botafogo <[hidden email]> wrote:

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






--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: JRubyFX simple EventHandler

Rodrigo Botafogo
Thanks....

2015-05-11 12:47 GMT-03:00 Thomas E Enebo <[hidden email]>:
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 Botafogo <[hidden email]> wrote:

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






--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: [hidden email]



--
Rodrigo Botafogo



Reply | Threaded
Open this post in threaded view
|

Re: JRubyFX simple EventHandler

Rodrigo Botafogo
In reply to this post by Thomas E Enebo
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 <[hidden email]>:
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 Botafogo <[hidden email]> wrote:

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






--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: [hidden email]



--
Rodrigo Botafogo