Weitere Ă€hnliche Inhalte Ăhnlich wie Developing cross platform desktop application with Ruby (20) KĂŒrzlich hochgeladen (20) Developing cross platform desktop application with Ruby2. I am...
PHP ZEND
KOHANA JSE JEE
Ruby GWT JavaScript
jQuery sinatra
BackboneJS CSS3
HTML5 MySQL Drupal
Anis Uddin Ahmad MongoDB PHPUNIT Groovy
CTO & Co-Founder JRuby Symfony2 SWING
WNeeds Ltd.
sqlite Doctrain solr Phing grails ...
6. generic purpose?
â
Web Application
â
Desktop Application
â
Mobile Application (Yes iPhone too!)
â
DSLs
â
Antyhing you can think*
8. Many Ways!
Shoes Ruby-GNOME2 / GTK
WxRuby Ruby-Tk
Ruby Cocoa / MacRuby
QtRuby JRuby + Swing
FxRuby JRuby + SWT
9. Many Ways!
Shoes Ruby-GNOME2 / GTK
WxRuby Ruby-Tk
Ruby Cocoa / MacRuby
QtRuby JRuby + Swing
FxRuby JRuby + SWT
23. Why JRuby?
â
High performance
â
Real threading
â
Vast array of libraries (gems + JARs)
24. Why JRuby?
â
High performance
â
Real threading
â
Vast array of libraries (gems + JARs)
â
Platform Independent
25. Why JRuby?
â
High performance
â
Real threading
â
Vast array of libraries (gems + JARs)
â
Platform Independent
â
Enterprise Acceptance
26. Why JRuby?
â
High performance
â
Real threading
â
Vast array of libraries (gems + JARs)
â
Platform Independent
â
Enterprise Acceptance
The best of both worlds!
28. 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
29. Import Java Swing in .rb
include Java
import javax.swing.JFrame
import javax.swing.JComboBox
import javax.swing.JButton
import javax.swing.JPanel
import javax.swing.JLabel
import javax.swing.JTextField
import java.awt.GridLayout
30. 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);
end
end
num_converter = NumberConverter.new
35. 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
36. Add the rest of
main.add(@input = JTextField.new(15))
# Second row
main.add(JLabel.new("Convert To : ", JLabel::RIGHT));
main.add(@cmbTo = JComboBox.new);
main.add(result = JTextField.new(15));
# Third row
main.add(JLabel.new(" ")); # Leave this cell blank
main.add(btn = JButton.new("CONVERT"));
40. 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
end
end # end of class NumFormat
44. Java <=> JRuby Transformation
new Car(color, wheels)
Car.new color, wheels
46. Java <=> JRuby Transformation
Obj.longFuncName();
Obj.long_func_name
47. Java <=> JRuby Transformation
String[] options = {"all", "any"};
combo = new JcomboBox(options);
options.each{ |format|
combo.add_item format
}
48. Java <=> JRuby Transformation
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
doSomething();
}
});
btn.add_action_listener do |evt|
do_something
end
49. Deployment
Warbler
http://rawr.rubyforge.org/ https://github.com/jruby/warbler
50. BTW, JRuby is not ONLY for Desktop
â
It's just Ruby*
â
Rails just works
*Here are differences- https://github.com/jruby/jruby/wiki/DifferencesBetweenMriAndJruby
51. JRuby Frameworks
https://github.com/jruby/jruby/wiki/GUIFrameworks
â
Cheri::Swing
â
Limelight
â
Monkeybars
â
RSwing
â
Rubeus
â
Swiby
52. JRuby Frameworks
https://github.com/jruby/jruby/wiki/GUIFrameworks
â
Cheri::Swing
â
Limelight
â
Monkeybars
â
RSwing
â
Rubeus
â
Swiby
Frame.new("hello, world") do |frame|
frame.default_close_operation = :exit_on_close
frame.size = [200, 200]
...