• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Developing cross platform desktop application with Ruby
 

Developing cross platform desktop application with Ruby

on

  • 9,944 views

A brief introduction and example of developing desktop application with Ruby programming language. JRuby and shoesrb is discussed as platform. ...

A brief introduction and example of developing desktop application with Ruby programming language. JRuby and shoesrb is discussed as platform.
Prepared for and Presented on Ruby Conference Bangladesh 2003.

Statistics

Views

Total Views
9,944
Views on SlideShare
9,868
Embed Views
76

Actions

Likes
11
Downloads
72
Comments
3

3 Embeds 76

https://twitter.com 45
http://www.linkedin.com 29
http://www.jruby.org 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

13 of 3 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • @anisniit no worries mate, spreading the voice is pretty much all I can do to contribute to the ruby dev environment, but I try to do it good :) and that's already a good thing considering my pretty contorted english :D I'm glad you liked the solutions I advised though, take your time to experiment with them :)
    Are you sure you want to
    Your message goes here
    Processing…
  • @janfryslide, Thanks a lot for the great info! I'll take a look soon will share my views with you.
    Thanks again.
    Are you sure you want to
    Your message goes here
    Processing…
  • Thanks for your talk. I think you missed a more recent and powerful approach to developing a desktop app with jruby:

    jrubyfx wrapper for javafx gui library
    https://github.com/jruby/jrubyfx/wiki/Getting-Started

    other than being a more modern and good looking gui library (and not only that), with javafx can have presentation code in a separate FXML file and you can also take advantage of the wonderful javafx scenebuilder visual designer!

    A app is not necessarily a game but as a side note I'd also have mentioned the usage of the free and powerful JMonkeyEngine 3D game engine with JRuby which, I think, is the most mature way (if you consider the few and incomplete alternatives) to work with 3D graphics and multimedia content using ruby code, at the moment:

    https://github.com/blaix/jme3-jruby-template

    I'd like to know what you think :)
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Developing cross platform desktop application with Ruby Developing cross platform desktop application with Ruby Presentation Transcript

    • Desktop Application with Ruby Getting started with
    • I am... PHP ZEND KOHANA JSE JEE Ruby GWT JavaScript jQuery sinatra BackboneJS CSS3 HTML5 MySQL DrupalAnis Uddin Ahmad MongoDB PHPUNIT GroovyCTO & Co-Founder JRuby Symfony2 SWINGWNeeds Ltd. sqlite Doctrain solr Phing grails ...
    • !=
    • Ruby is not ONLY for web
    • Its a generic purpose language
    • generic purpose?● Web Application● Desktop Application● Mobile Application (Yes iPhone too!)● DSLs● Antyhing you can think*
    • So, Ruby can make Desktop App? Okay... But HOW?
    • Many Ways! Shoes Ruby-GNOME2 / GTKWxRuby Ruby-Tk Ruby Cocoa / MacRubyQtRuby JRuby + Swing FxRuby JRuby + SWT
    • Many Ways! Shoes Ruby-GNOME2 / GTKWxRuby Ruby-Tk Ruby Cocoa / MacRubyQtRuby JRuby + Swing FxRuby JRuby + SWT
    • Shoes cross-platform toolkit forwriting graphical apps easily and artfully using Ruby
    • Starting with Shoes● Download (http://shoesrb.com/downloads))● Run Shoes
    • Starting with Shoes● Download (http://shoesrb.com/downloads))● Run Shoes
    • Shoes exampleShoes.app :width => 300, :height => 200 do  button("Click me!") { alert("Good job.") }end
    • Shoes exampleShoes.app :width => 300, :height => 200 do  button("Click me!") { alert("Good job.") }end
    • Shoes example (Clock)Shoes.app do  @time = title "0:00"  every 1 do    @time.replace(Time.now.strftime("%I:%M %p"))  endend
    • Hackety Hack! http://hackety.com/
    • Packaging Shoes
    • JRubyThe Ruby Programming Language on the JVM
    • Ruby for desktop application? Yes we can!
    • The Redcar Editor http://redcareditor.com/
    • Why JRuby?● High performance
    • Why JRuby?● High performance● Real threading
    • Why JRuby?● High performance● Real threading● Vast array of libraries (gems + JARs)
    • Why JRuby?● High performance● Real threading● Vast array of libraries (gems + JARs)● Platform Independent
    • Why JRuby?● High performance● Real threading● Vast array of libraries (gems + JARs)● Platform Independent● Enterprise Acceptance
    • Why JRuby?● High performance● Real threading● Vast array of libraries (gems + JARs)● Platform Independent● Enterprise Acceptance The best of both worlds!
    • Lets make with JRuby!
    • Get JRuby● Download● Extract● Add bin subdirectory to your $PATH – (PATH=path/to/jruby/bin:$PATH)● Test it: jruby -v● Assuming you have jdk 1.7 installed● Can be installed with rvm too
    • Import Java Swing in .rbinclude Javaimport javax.swing.JFrameimport javax.swing.JComboBoximport javax.swing.JButtonimport javax.swing.JPanelimport javax.swing.JLabelimport javax.swing.JTextFieldimport java.awt.GridLayout
    • Make a Frame (JFrame)class NumberConverter < JFrame def initialize super(Number Format Converter) set_size(400,140); set_visible(true);       set_default_close_operation(JFrame::EXIT_ON_CLOSE); endendnum_converter = NumberConverter.new
    • Lets run it!$ cd go/to/source/dir$ jruby number_converter.rb
    • Place containersuper(Number Format Converter)main = JPanel.new;get_content_pane().add("Center", main);
    • Set Layoutsuper(Number Format Converter)main = JPanel.new;main.set_layout(GridLayout.new(3,3,2,2))get_content_pane().add("Center", main)
    • Add Componentsmain.set_layout(GridLayout.new(3,3,2,2))main.add(JLabel.new("Convert From : ", JLabel::RIGHT))main.add(@cmbFrom = JComboBox.new)main.add(@input = JTextField.new(15))
    • Where are they going?main.set_layout(GridLayout.new(3,3,2,2))main.add(JLabel.new("Convert From : ", JLabel::RIGHT))main.add(@cmbFrom = JComboBox.new)main.add(@input = JTextField.new(15)) 1 2 3 4 5 6 7 8 9
    • Add the rest ofmain.add(@input = JTextField.new(15))# Second rowmain.add(JLabel.new("Convert To : ", JLabel::RIGHT));main.add(@cmbTo = JComboBox.new);main.add(result = JTextField.new(15));# Third rowmain.add(JLabel.new(" ")); # Leave this cell blankmain.add(btn = JButton.new("CONVERT"));
    • Lets run again!$ cd go/to/source/dir$ jruby number_converter.rb
    • More with componentsmain.add(result = JTextField.new(15));result.set_editable(false);main.add(btn = Jbutton.new("CONVERT"));# Add options to comboBoxesnum_formats = ["Decimal", "Binary", "HexaDecimal", "Octal"]num_formats.each{|format| @cmbFrom.add_item format }num_formats.each{|format| @cmbTo.add_item format }
    • Set Event Handlermain.add(btn = Jbutton.new("CONVERT"));btn.add_action_listener do |evt| result.set_text(convert.upcase);end
    • Set Event Handler cont.main.add(btn = Jbutton.new("CONVERT"));btn.add_action_listener do |evt| result.set_text(convert.upcase);end def convert # Take the value of @input # Take formats form @cmbFrom and @cmbTo # Convert to required format endend # end of class NumFormat
    • Yep! Its Done!!https://github.com/ajaxray/jruby-swing
    • Java <=> JRuby Transformation
    • Java <=> JRuby Transformationnew Car(color, wheels)Car.new color, wheels
    • Java <=> JRuby TransformationJLabel.LEFTJLabel::LEFT
    • Java <=> JRuby TransformationObj.longFuncName();Obj.long_func_name
    • Java <=> JRuby TransformationString[] options = {"all", "any"};combo = new JcomboBox(options);options.each{ |format| combo.add_item format}
    • Java <=> JRuby Transformationbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { doSomething(); }});btn.add_action_listener do |evt| do_somethingend
    • Deployment Warblerhttp://rawr.rubyforge.org/ https://github.com/jruby/warbler
    • BTW, JRuby is not ONLY for Desktop● Its just Ruby*● Rails just works *Here are differences- https://github.com/jruby/jruby/wiki/DifferencesBetweenMriAndJruby
    • JRuby Frameworks https://github.com/jruby/jruby/wiki/GUIFrameworks● Cheri::Swing● Limelight● Monkeybars● RSwing● Rubeus● Swiby
    • JRuby Frameworks https://github.com/jruby/jruby/wiki/GUIFrameworks● Cheri::Swing● Limelight● Monkeybars● RSwing● Rubeus● SwibyFrame.new("hello, world") do |frame| frame.default_close_operation = :exit_on_close frame.size = [200, 200] ...
    • Questions?