Skip to content

Commit

Permalink
Update swing example
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@8723 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
enebo committed Jan 12, 2009
1 parent 42b98a6 commit f48b8b1
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions samples/swing2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.