-
-
Save headius/5dca771a8a09c7ee5aa331f1406a97ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import Java packages | |
include Java | |
java_import javax.swing.JFrame | |
frame = JFrame.new("Hello Swing") | |
button = javax.swing.JButton.new("Klick Me!") | |
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 | |
# Add the button to the frame | |
frame.content_pane.add(button) | |
# Show frame | |
frame.default_close_operation = JFrame::EXIT_ON_CLOSE | |
frame.pack | |
frame.visible = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment