-
Notifications
You must be signed in to change notification settings - Fork 4
/
README
53 lines (38 loc) · 1.74 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
== RSwing - Swing wrapper for JRuby
RSwing is licensed under the GNU LGPL v3. For more information, take a look at
the LICENSE file.
================================================================================
RSwing is a wrapper of the Swing GUI-Framework of the Java Platform for JRuby.
The goal is to provide a ruby-ish wrapper library to Swing, which makes it feel
more like an actual ruby library rather than just a plain interface to the java
classes.
For example, RSwing tries to make heavy use of blocks, symbols and similar
typical ruby concepts.
================================================================================
Some examples:
Frame.new("hello, world") do |frame|
frame.default_close_operation = :exit_on_close
frame.size = [200,200]
# create a new button, belonging to this frame with a given name to access it easily later
Button.new("OK", :belongs_to => frame, :name => :okButton) do |btn|
btn.on_click do
Dialog.show "Button clicked!", :dialog_type => :info, :title => "My Title", :belongs_to => frame
end
btn.on_focus do
puts "button has now focus"
end
btn.on_focus_lost do
puts "button has lost focus"
end
end
# accessing components of frame via :name attribute given to button:
puts "text property of okButton: #{frame[:okButton].text}"
# options-dialog
options = ["Yes", "No", "Cancel"]
selected_value = Dialog.show_option(options.join(" or ") + "?",
:option_values => options,
:option_type => :yes_no_cancel,
:belongs_to => frame)
puts "#{selected_value} was selected"
frame.visible = true
end