Skip to content
Browse files

Update swing example

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@8723 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 42b98a6 commit f48b8b12e685df7b15c737ff2eb2d248246fabfe @enebo enebo committed
Showing with 3 additions and 11 deletions.
  1. +3 −11 samples/swing2.rb
View
14 samples/swing2.rb
@@ -5,17 +5,12 @@
frame = JFrame.new("Hello Swing")
button = javax.swing.JButton.new("Klick Me!")
-
-class ClickAction
- include java.awt.event.ActionListener
- def actionPerformed(evt)
- javax.swing.JOptionPane.showMessageDialog(nil, <<EOS)
-<html>Hello from <b><u>JRuby</u></b>.<br>
+button.add_action_listener do |evt|
+ javax.swing.JOptionPane.showMessageDialog(nil, <<EOS)
+<html>Hello from <b><u>JRuby</u></b>.<br>
Button '#{evt.getActionCommand()}' clicked.
EOS
- end
end
-button.add_action_listener(ClickAction.new)
# Add the button to the frame
frame.get_content_pane.add(button)
@@ -24,6 +19,3 @@ def actionPerformed(evt)
frame.set_default_close_operation(JFrame::EXIT_ON_CLOSE)
frame.pack
frame.visible = true
-
-# Sleep the main thread, so we don't exit
-Thread.stop

0 comments on commit f48b8b1

Please sign in to comment.
Something went wrong with that request. Please try again.