Created
August 10, 2011 02:43
-
-
Save opamp/1135966 to your computer and use it in GitHub Desktop.
Swing_test-JRuby
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
#!/usr/local/bin/ruby --1.9 | |
#-*- encoding: utf-8 -*- | |
require 'java' | |
import 'javax.swing.JFrame' | |
import 'javax.swing.JButton' | |
import 'javax.swing.JTextField' | |
import 'javax.swing.JTextArea' | |
import 'javax.swing.JPanel' | |
import 'java.awt.BorderLayout' | |
class ButtonAction | |
include java.awt.event.ActionListener | |
def initialize(area,text) | |
@ar = area | |
@tx = text | |
end | |
def actionPerformed(evt) | |
@ar.append(@tx.getText()) | |
end | |
end | |
frame = JFrame.new("MainWindow") | |
button = JButton.new("OK") | |
text = JTextField.new(15) | |
area = JTextArea.new() | |
area.setRows(15) | |
area.setColumns(20) | |
button.add_action_listener(ButtonAction.new(area,text)) | |
panel = JPanel.new | |
panel.add text | |
panel.add button | |
panel.add area | |
frame.getContentPane.add(panel, BorderLayout::CENTER) | |
frame.setDefaultCloseOperation(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