JRuby used to make JFrame
Code: "gui_swing2.rb". Programming language: Ruby DMelt Version 1. Last modified: 12/10/2015. License: Pro
https://datamelt.org/code/cache/gui_swing2_835.rb
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



include 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, <Hello from JRuby.
Button '#{evt.getActionCommand()}' clicked. EOS end # Add the button to the frame frame.get_content_pane.add(button) # Show frame frame.set_default_close_operation(JFrame::EXIT_ON_CLOSE) frame.pack frame.visible = true

Ads help maintain this website.