swing_paradise 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of swing_paradise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +1557 -0
- data/doc/README.gen +1510 -0
- data/lib/swing_paradise/autoinclude.rb +3 -0
- data/lib/swing_paradise/awt/README.md +1 -0
- data/lib/swing_paradise/awt/color.rb +45 -0
- data/lib/swing_paradise/base_module/base_module.rb +993 -0
- data/lib/swing_paradise/classes +1 -0
- data/lib/swing_paradise/examples/001_quit_button_example.rb +55 -0
- data/lib/swing_paradise/examples/002_text_area_example.rb +55 -0
- data/lib/swing_paradise/examples/003_combo_box_example.rb +57 -0
- data/lib/swing_paradise/examples/004_jpanel_left_bound_example.rb +41 -0
- data/lib/swing_paradise/examples/005_box_layout_example.rb +39 -0
- data/lib/swing_paradise/examples/006_frame_example.rb +33 -0
- data/lib/swing_paradise/examples/007_textarea_responding_to_enter_key_example.rb +28 -0
- data/lib/swing_paradise/examples/008_scrolled_window_example.rb +41 -0
- data/lib/swing_paradise/examples/009_font_size_example.rb +39 -0
- data/lib/swing_paradise/examples/010_counter_example.rb +183 -0
- data/lib/swing_paradise/examples/011_button_with_image_example.rb +58 -0
- data/lib/swing_paradise/examples/012_quit_on_escape_key_being_pressed.rb +37 -0
- data/lib/swing_paradise/examples/013_simple_box_example.rb +38 -0
- data/lib/swing_paradise/examples/014_mouse_events_example.rb +41 -0
- data/lib/swing_paradise/examples/015_menu_example.rb +77 -0
- data/lib/swing_paradise/examples/016_file_chooser_example.rb +96 -0
- data/lib/swing_paradise/examples/017_buttons_example.rb +56 -0
- data/lib/swing_paradise/examples/018_colour_chooser_example.rb +51 -0
- data/lib/swing_paradise/examples/019_jeditorpane_example.rb +61 -0
- data/lib/swing_paradise/examples/020_table_example.rb +77 -0
- data/lib/swing_paradise/examples/021_jsplitpane_example.rb +66 -0
- data/lib/swing_paradise/examples/022_drawing_oval_example.rb +51 -0
- data/lib/swing_paradise/examples/023_show_message_dialog_example.rb +57 -0
- data/lib/swing_paradise/java_classes/border_factory/border_factory.rb +19 -0
- data/lib/swing_paradise/java_classes/box/box.rb +72 -0
- data/lib/swing_paradise/java_classes/button +1 -0
- data/lib/swing_paradise/java_classes/checkbox +1 -0
- data/lib/swing_paradise/java_classes/combobox +1 -0
- data/lib/swing_paradise/java_classes/default_table_model/default_table_model.rb +18 -0
- data/lib/swing_paradise/java_classes/frame +1 -0
- data/lib/swing_paradise/java_classes/jbutton/jbutton.rb +199 -0
- data/lib/swing_paradise/java_classes/jcheckbox/jcheckbox.rb +28 -0
- data/lib/swing_paradise/java_classes/jcombobox/jcombobox.rb +31 -0
- data/lib/swing_paradise/java_classes/jcomponent/jcomponent.rb +253 -0
- data/lib/swing_paradise/java_classes/jeditorpane/jeditorpane.rb +23 -0
- data/lib/swing_paradise/java_classes/jfilechooser/jfilechooser.rb +22 -0
- data/lib/swing_paradise/java_classes/jframe/jframe.rb +319 -0
- data/lib/swing_paradise/java_classes/jlabel/jlabel.rb +171 -0
- data/lib/swing_paradise/java_classes/jmenu/jmenu.rb +13 -0
- data/lib/swing_paradise/java_classes/jmenubar/jmenubar.rb +13 -0
- data/lib/swing_paradise/java_classes/jpanel/jpanel.rb +115 -0
- data/lib/swing_paradise/java_classes/jscrollpane/jscrollpane.rb +84 -0
- data/lib/swing_paradise/java_classes/jspinner/jspinner.rb +17 -0
- data/lib/swing_paradise/java_classes/jtextarea/jtextarea.rb +120 -0
- data/lib/swing_paradise/java_classes/jtextfield/jtextfield.rb +314 -0
- data/lib/swing_paradise/java_classes/label +1 -0
- data/lib/swing_paradise/java_classes/panel +1 -0
- data/lib/swing_paradise/java_classes/spinner +1 -0
- data/lib/swing_paradise/java_classes/textarea +1 -0
- data/lib/swing_paradise/misc/misc.rb +57 -0
- data/lib/swing_paradise/prototype/prototype.rb +79 -0
- data/lib/swing_paradise/requires/require_the_project.rb +15 -0
- data/lib/swing_paradise/toplevel_methods/misc.rb +293 -0
- data/lib/swing_paradise/version/version.rb +17 -0
- data/lib/swing_paradise/widget_collection/README.md +2 -0
- data/lib/swing_paradise/widget_collection/text_viewer.rb +160 -0
- data/lib/swing_paradise.rb +1 -0
- data/swing_paradise.gemspec +42 -0
- metadata +120 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jscrollpane/jscrollpane.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
class Java::JavaxSwing::JScrollPane
|
5
|
+
|
6
|
+
# ========================================================================= #
|
7
|
+
# === use_this_font=
|
8
|
+
# ========================================================================= #
|
9
|
+
alias use_this_font= setFont
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === vertical_scrollbar_always
|
13
|
+
# ========================================================================= #
|
14
|
+
def vertical_scrollbar_always
|
15
|
+
setVerticalScrollBarPolicy(
|
16
|
+
JScrollPane::VERTICAL_SCROLLBAR_ALWAYS
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
# ========================================================================= #
|
21
|
+
# === always_policy
|
22
|
+
# ========================================================================= #
|
23
|
+
def always_policy
|
24
|
+
horizontal_always
|
25
|
+
vertical_always
|
26
|
+
end
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === horizontal_always
|
30
|
+
# ========================================================================= #
|
31
|
+
def horizontal_always
|
32
|
+
setHorizontalScrollBarPolicy(JScrollPane::HORIZONTAL_SCROLLBAR_ALWAYS)
|
33
|
+
end
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === vertical_always
|
37
|
+
# ========================================================================= #
|
38
|
+
def vertical_always
|
39
|
+
setVerticalScrollBarPolicy(JScrollPane::VERTICAL_SCROLLBAR_ALWAYS)
|
40
|
+
end
|
41
|
+
|
42
|
+
# ========================================================================= #
|
43
|
+
# === dimensions
|
44
|
+
#
|
45
|
+
# This is just a wrapper over setBounds() to allow us to work with
|
46
|
+
# a Hash instead.
|
47
|
+
# ========================================================================= #
|
48
|
+
def dimensions(
|
49
|
+
hash = {
|
50
|
+
x_axis: 10,
|
51
|
+
y_axis: 20,
|
52
|
+
width: 300,
|
53
|
+
height: 50
|
54
|
+
}
|
55
|
+
)
|
56
|
+
# is: x-coordinate, y-coordinate, width, height)
|
57
|
+
setBounds(
|
58
|
+
hash[:x_axis],
|
59
|
+
hash[:y_axis],
|
60
|
+
hash[:width],
|
61
|
+
hash[:height]
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
# ========================================================================= #
|
66
|
+
# === bblack1
|
67
|
+
#
|
68
|
+
# For now this method doesn't do anything; in the future we should
|
69
|
+
# create a black border through this method.
|
70
|
+
# ========================================================================= #
|
71
|
+
def bblack1
|
72
|
+
end
|
73
|
+
|
74
|
+
# ========================================================================= #
|
75
|
+
# === pad5px
|
76
|
+
# ========================================================================= #
|
77
|
+
def pad3px; end
|
78
|
+
def pad4px; end
|
79
|
+
def pad5px; end
|
80
|
+
def pad6px; end
|
81
|
+
def pad7px; end
|
82
|
+
def pad8px; end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Java::JavaxSwing::JSpinner
|
2
|
+
|
3
|
+
# ========================================================================= #
|
4
|
+
# === text?
|
5
|
+
# ========================================================================= #
|
6
|
+
def text?
|
7
|
+
getValue.to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === background=
|
12
|
+
# ========================================================================= #
|
13
|
+
def background=(i)
|
14
|
+
getEditor.getComponent(0).setBackground(i)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jtextarea/jtextarea.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
java_import javax.swing.border.Border
|
5
|
+
java_import javax.swing.BorderFactory
|
6
|
+
|
7
|
+
class Java::JavaxSwing::JTextArea
|
8
|
+
|
9
|
+
alias original_set_font set_font # === original_set_font
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === set_content
|
13
|
+
# ========================================================================= #
|
14
|
+
def set_content(i)
|
15
|
+
set_text(i.to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
# ========================================================================= #
|
19
|
+
# === use_this_font=
|
20
|
+
# ========================================================================= #
|
21
|
+
def use_this_font=(i)
|
22
|
+
if i.is_a?(String) or i.is_a?(Symbol)
|
23
|
+
i = SwingParadise.jruby_font(i)
|
24
|
+
end
|
25
|
+
setFont(i)
|
26
|
+
end
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === set_font
|
30
|
+
# ========================================================================= #
|
31
|
+
def set_font(i = :hack_25)
|
32
|
+
original_set_font(
|
33
|
+
SwingParadise.jruby_font(i)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# ========================================================================= #
|
38
|
+
# === on_enter_key_pressed
|
39
|
+
# ========================================================================= #
|
40
|
+
# def on_enter_key_pressed(&block)
|
41
|
+
# addActionListener(&block)
|
42
|
+
# end
|
43
|
+
|
44
|
+
# ========================================================================= #
|
45
|
+
# === filter_newlines
|
46
|
+
# ========================================================================= #
|
47
|
+
def filter_newlines
|
48
|
+
getDocument.putProperty('filterNewlines', true)
|
49
|
+
end
|
50
|
+
|
51
|
+
# ========================================================================= #
|
52
|
+
# === x_y_width_height
|
53
|
+
# ========================================================================= #
|
54
|
+
def x_y_width_height(
|
55
|
+
x = 200,
|
56
|
+
y = 320,
|
57
|
+
width = 600,
|
58
|
+
height = 350
|
59
|
+
)
|
60
|
+
setBounds(x, y, width, height) # x, y, width, height
|
61
|
+
end
|
62
|
+
|
63
|
+
# ========================================================================= #
|
64
|
+
# === make_border
|
65
|
+
# ========================================================================= #
|
66
|
+
def make_border(
|
67
|
+
use_this_colour = Color::BLACK,
|
68
|
+
width_of_the_border = 3
|
69
|
+
)
|
70
|
+
setBorder(
|
71
|
+
BorderFactory.createLineBorder(use_this_colour, width_of_the_border)
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === clear
|
77
|
+
# ========================================================================= #
|
78
|
+
def clear
|
79
|
+
set_text('')
|
80
|
+
end
|
81
|
+
|
82
|
+
# ========================================================================= #
|
83
|
+
# === dimensions
|
84
|
+
#
|
85
|
+
# This is just a wrapper over setBounds() to allow us to work with
|
86
|
+
# a Hash instead.
|
87
|
+
# ========================================================================= #
|
88
|
+
def dimensions(
|
89
|
+
hash = {
|
90
|
+
x_axis: 10,
|
91
|
+
y_axis: 20,
|
92
|
+
width: 300,
|
93
|
+
height: 50
|
94
|
+
}
|
95
|
+
)
|
96
|
+
# is: x-coordinate, y-coordinate, width, height)
|
97
|
+
setBounds(
|
98
|
+
hash[:x_axis],
|
99
|
+
hash[:y_axis],
|
100
|
+
hash[:width],
|
101
|
+
hash[:height]
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# ========================================================================= #
|
106
|
+
# === text?
|
107
|
+
# ========================================================================= #
|
108
|
+
def text?
|
109
|
+
getText
|
110
|
+
end
|
111
|
+
|
112
|
+
# Currently not implemented.
|
113
|
+
def pad8px
|
114
|
+
end
|
115
|
+
|
116
|
+
def visible_cursor
|
117
|
+
e 'visible_cursor has not yet been implemented.'
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,314 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'swing_paradise/java_classes/jtextfield/jtextfield.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
# java_import 'javax.swing.text.JTextComponent'
|
8
|
+
# =========================================================================== #
|
9
|
+
# https://docs.oracle.com/javase/8/docs/api/javax/swing/JTextField.html
|
10
|
+
# =========================================================================== #
|
11
|
+
class Java::JavaxSwing::JTextField
|
12
|
+
|
13
|
+
alias original_set_font set_font # === original_set_font
|
14
|
+
|
15
|
+
alias select_everything selectAll # === select_everything
|
16
|
+
|
17
|
+
# ========================================================================= #
|
18
|
+
# === on_mouse_click_select_everything
|
19
|
+
#
|
20
|
+
# This method will, upon left-mouse-button press event, select the
|
21
|
+
# whole JTextField.
|
22
|
+
#
|
23
|
+
# The method works, as verified in January 2024.
|
24
|
+
# ========================================================================= #
|
25
|
+
def on_mouse_click_select_everything
|
26
|
+
mouse_listener {|event|
|
27
|
+
if left_mouse_click?(event)
|
28
|
+
requestFocus # ← This may not be necessary, but let's see nonetheless.
|
29
|
+
select_everything # or: select(0, getText.length)
|
30
|
+
end
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# ========================================================================= #
|
35
|
+
# === set_maxsize
|
36
|
+
#
|
37
|
+
# This is currently not implemented.
|
38
|
+
# ========================================================================= #
|
39
|
+
def set_maxsize(i = 1)
|
40
|
+
# if length > i
|
41
|
+
# end
|
42
|
+
end
|
43
|
+
|
44
|
+
# ========================================================================= #
|
45
|
+
# === signal_connect
|
46
|
+
# ========================================================================= #
|
47
|
+
def signal_connect(i = '', &block)
|
48
|
+
e '.signal_connect() is not yet implemented.'
|
49
|
+
end
|
50
|
+
|
51
|
+
# ========================================================================= #
|
52
|
+
# === on_enter_key_pressed
|
53
|
+
# ========================================================================= #
|
54
|
+
def on_enter_key_pressed(&block)
|
55
|
+
addActionListener(&block)
|
56
|
+
end; alias on_enter_key on_enter_key_pressed # === on_enter_key
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === do_focus
|
60
|
+
# ========================================================================= #
|
61
|
+
def do_focus
|
62
|
+
requestFocusInWindow()
|
63
|
+
end
|
64
|
+
|
65
|
+
# ========================================================================= #
|
66
|
+
# === the_user_may_not_modify_this_entry
|
67
|
+
#
|
68
|
+
# This method will disallow any user-driven changes to the JTextfield
|
69
|
+
# at hand.
|
70
|
+
# ========================================================================= #
|
71
|
+
def the_user_may_not_modify_this_entry
|
72
|
+
setEditable(false)
|
73
|
+
end; alias disallow_changes the_user_may_not_modify_this_entry # === disallow_changes
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === use_this_font=
|
77
|
+
# ========================================================================= #
|
78
|
+
def use_this_font=(i)
|
79
|
+
if i.is_a?(String) or i.is_a?(Symbol)
|
80
|
+
i = SwingParadise.jruby_font(i)
|
81
|
+
end
|
82
|
+
setFont(i)
|
83
|
+
end
|
84
|
+
|
85
|
+
# ========================================================================= #
|
86
|
+
# === center
|
87
|
+
# ========================================================================= #
|
88
|
+
def center
|
89
|
+
setHorizontalAlignment(JTextField::CENTER)
|
90
|
+
end; alias align_to_the_center center # === center
|
91
|
+
alias do_center center # === do_center
|
92
|
+
|
93
|
+
# ========================================================================= #
|
94
|
+
# === on_enter
|
95
|
+
# ========================================================================= #
|
96
|
+
def on_enter(&block)
|
97
|
+
addActionListener {|event|
|
98
|
+
if event.getKeyCode == KeyEvent::VK_ENTER
|
99
|
+
e 'ENTER WAS PRESSED.'
|
100
|
+
end
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
# ========================================================================= #
|
105
|
+
# === hint=
|
106
|
+
# ========================================================================= #
|
107
|
+
def hint=(i = '')
|
108
|
+
setToolTipText(i)
|
109
|
+
end; alias fancy_hint= hint= # === fancy_hint=
|
110
|
+
|
111
|
+
# ========================================================================= #
|
112
|
+
# === shadow_hint=
|
113
|
+
# ========================================================================= #
|
114
|
+
def shadow_hint=(i = '')
|
115
|
+
e 'Todo: implement shadow_hint='
|
116
|
+
end
|
117
|
+
|
118
|
+
# ========================================================================= #
|
119
|
+
# === set_background_colour
|
120
|
+
#
|
121
|
+
# Colours can also be set via:
|
122
|
+
#
|
123
|
+
# java.awt.Color.new(175, 238, 238)
|
124
|
+
#
|
125
|
+
# ========================================================================= #
|
126
|
+
def set_background_colour(i = ::Color::RED)
|
127
|
+
setBackground(i)
|
128
|
+
end
|
129
|
+
|
130
|
+
# ========================================================================= #
|
131
|
+
# === set_font
|
132
|
+
# ========================================================================= #
|
133
|
+
def set_font(i = :hack_25)
|
134
|
+
original_set_font(
|
135
|
+
SwingParadise.jruby_font(i)
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
# ========================================================================= #
|
140
|
+
# === dimensions
|
141
|
+
#
|
142
|
+
# This is just a wrapper over setBounds() to allow us to work with
|
143
|
+
# a Hash instead.
|
144
|
+
# ========================================================================= #
|
145
|
+
def dimensions(
|
146
|
+
hash = {
|
147
|
+
x_axis: 10,
|
148
|
+
y_axis: 20,
|
149
|
+
width: 300,
|
150
|
+
height: 50
|
151
|
+
}
|
152
|
+
)
|
153
|
+
# is: x-coordinate, y-coordinate, width, height)
|
154
|
+
setBounds(
|
155
|
+
hash[:x_axis],
|
156
|
+
hash[:y_axis],
|
157
|
+
hash[:width],
|
158
|
+
hash[:height]
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
# ========================================================================= #
|
163
|
+
# === enable_dragging
|
164
|
+
# ========================================================================= #
|
165
|
+
def enable_dragging
|
166
|
+
setDragEnabled(true)
|
167
|
+
end
|
168
|
+
|
169
|
+
# ========================================================================= #
|
170
|
+
# === text?
|
171
|
+
# ========================================================================= #
|
172
|
+
def text?
|
173
|
+
getText.to_s
|
174
|
+
end
|
175
|
+
|
176
|
+
# ========================================================================= #
|
177
|
+
# === default=
|
178
|
+
# ========================================================================= #
|
179
|
+
def default=(i)
|
180
|
+
setText(i.to_s)
|
181
|
+
end
|
182
|
+
|
183
|
+
alias set_text setText # === set_text
|
184
|
+
|
185
|
+
alias width_height set_size # === width_height
|
186
|
+
alias set_size_request set_size # === set_size_request
|
187
|
+
|
188
|
+
# ========================================================================= #
|
189
|
+
# === <<
|
190
|
+
# ========================================================================= #
|
191
|
+
def <<(i)
|
192
|
+
setText(i)
|
193
|
+
end
|
194
|
+
|
195
|
+
# ========================================================================= #
|
196
|
+
# === on_enter_pressed
|
197
|
+
# ========================================================================= #
|
198
|
+
def on_enter_pressed(&block)
|
199
|
+
add_action_listener(&block)
|
200
|
+
end
|
201
|
+
|
202
|
+
# ========================================================================= #
|
203
|
+
# Past this points we'll have stubs. These may be improved at a later time,
|
204
|
+
# or never. Either way they have to be defined, at the least.
|
205
|
+
# ========================================================================= #
|
206
|
+
|
207
|
+
# ========================================================================= #
|
208
|
+
# === highlight_on_click_event
|
209
|
+
# ========================================================================= #
|
210
|
+
def highlight_on_click_event
|
211
|
+
end
|
212
|
+
|
213
|
+
# ========================================================================= #
|
214
|
+
# === add_css_class
|
215
|
+
# ========================================================================= #
|
216
|
+
def add_css_class(i = '')
|
217
|
+
end
|
218
|
+
|
219
|
+
# ========================================================================= #
|
220
|
+
# === pad4px
|
221
|
+
# ========================================================================= #
|
222
|
+
def pad4px
|
223
|
+
end
|
224
|
+
|
225
|
+
# ========================================================================= #
|
226
|
+
# === bblack1
|
227
|
+
# ========================================================================= #
|
228
|
+
def bblack1
|
229
|
+
end
|
230
|
+
|
231
|
+
# ========================================================================= #
|
232
|
+
# === bblack2
|
233
|
+
# ========================================================================= #
|
234
|
+
def bblack2
|
235
|
+
end
|
236
|
+
|
237
|
+
# ========================================================================= #
|
238
|
+
# === bblack3
|
239
|
+
# ========================================================================= #
|
240
|
+
def bblack3
|
241
|
+
end
|
242
|
+
|
243
|
+
# ========================================================================= #
|
244
|
+
# === bblack4
|
245
|
+
# ========================================================================= #
|
246
|
+
def bblack4
|
247
|
+
end
|
248
|
+
|
249
|
+
# ========================================================================= #
|
250
|
+
# === bblack5
|
251
|
+
# ========================================================================= #
|
252
|
+
def bblack5
|
253
|
+
end
|
254
|
+
|
255
|
+
# ========================================================================= #
|
256
|
+
# === clear_background
|
257
|
+
#
|
258
|
+
# This method currently does not do anything, as it is only necessary
|
259
|
+
# in ruby-gtk3 really.
|
260
|
+
# ========================================================================= #
|
261
|
+
def clear_background
|
262
|
+
end
|
263
|
+
|
264
|
+
# ========================================================================= #
|
265
|
+
# === css_class
|
266
|
+
#
|
267
|
+
# This method currently does not work.
|
268
|
+
# ========================================================================= #
|
269
|
+
def css_class(i = '')
|
270
|
+
end
|
271
|
+
|
272
|
+
# ========================================================================= #
|
273
|
+
# === make_bold
|
274
|
+
# ========================================================================= #
|
275
|
+
def make_bold(
|
276
|
+
font_size = 20
|
277
|
+
)
|
278
|
+
setFont(
|
279
|
+
getFont.deriveFont(Font::BOLD, font_size)
|
280
|
+
)
|
281
|
+
end
|
282
|
+
|
283
|
+
# ========================================================================= #
|
284
|
+
# === on_click_select_all
|
285
|
+
# ========================================================================= #
|
286
|
+
def on_click_select_all(&block)
|
287
|
+
e 'Todo: implement on-click-select-all.'
|
288
|
+
end
|
289
|
+
|
290
|
+
# ========================================================================= #
|
291
|
+
# === on_key_press_event
|
292
|
+
# ========================================================================= #
|
293
|
+
def on_key_press_event(&block)
|
294
|
+
e 'Todo: implement on-key-press-event.'
|
295
|
+
end
|
296
|
+
|
297
|
+
# ========================================================================= #
|
298
|
+
# === very_light_yellow_background
|
299
|
+
# ========================================================================= #
|
300
|
+
def very_light_yellow_background
|
301
|
+
set_background_colour(
|
302
|
+
java.awt.Color.new(99, 99, 83)
|
303
|
+
)
|
304
|
+
end; alias very_light_yellowish_background very_light_yellow_background # === very_light_yellowish_background
|
305
|
+
|
306
|
+
def set_activates_default(i = nil)
|
307
|
+
e 'Todo: implement set_activates_default or ignore it.'
|
308
|
+
end
|
309
|
+
|
310
|
+
def enable_events
|
311
|
+
e 'enable_events has not yet been implemented.'
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
jlabel
|
@@ -0,0 +1 @@
|
|
1
|
+
jpanel
|
@@ -0,0 +1 @@
|
|
1
|
+
jspinner
|
@@ -0,0 +1 @@
|
|
1
|
+
jtextarea
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'swing_paradise/misc/misc.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module SwingParadise
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === SwingParadise.window
|
11
|
+
#
|
12
|
+
# This is ultimately a wrapper over JFrame.
|
13
|
+
# ========================================================================= #
|
14
|
+
def self.window(
|
15
|
+
width = 640,
|
16
|
+
height = 480
|
17
|
+
)
|
18
|
+
require 'swing_paradise/java_classes/jframe/jframe.rb'
|
19
|
+
widget = Java::JavaxSwing::JFrame.new
|
20
|
+
if width and height
|
21
|
+
widget.width_height(width, height)
|
22
|
+
end
|
23
|
+
return widget
|
24
|
+
end; self.instance_eval { alias create_frame window } # === SwingParadise.create_frame
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === SwingParadise.frame
|
28
|
+
# ========================================================================= #
|
29
|
+
def self.frame(frame_title = '')
|
30
|
+
JFrame.new(frame_title)
|
31
|
+
end
|
32
|
+
|
33
|
+
# ========================================================================= #
|
34
|
+
# === SwingParadise.jpanel
|
35
|
+
# ========================================================================= #
|
36
|
+
def self.jpanel
|
37
|
+
JPanel.new
|
38
|
+
end; self.instance_eval { alias panel jpanel } # === SwingParadise.panel
|
39
|
+
|
40
|
+
# ========================================================================= #
|
41
|
+
# === jframe
|
42
|
+
# ========================================================================= #
|
43
|
+
def jframe(frame_title = '')
|
44
|
+
::SwingParadise.frame(frame_title)
|
45
|
+
end; alias frame jframe # === frame
|
46
|
+
|
47
|
+
# ========================================================================= #
|
48
|
+
# === jtextview
|
49
|
+
#
|
50
|
+
# JTextArea is the one for multi-line input.
|
51
|
+
# ========================================================================= #
|
52
|
+
def jtextview(i = '')
|
53
|
+
JTextArea.new(i)
|
54
|
+
end; alias text_view jtextview # === text_view
|
55
|
+
alias textview jtextview # === textview
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# This is the prototype for jruby-swing applications.
|
6
|
+
# =========================================================================== #
|
7
|
+
include Java
|
8
|
+
|
9
|
+
module SwingParadise
|
10
|
+
|
11
|
+
class Prototype < javax.swing.JFrame
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include ::SwingParadise::BaseModule # Scope onto the toplevel here.
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === WIDTH
|
18
|
+
# ========================================================================= #
|
19
|
+
WIDTH = 1420
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === HEIGHT
|
23
|
+
# ========================================================================= #
|
24
|
+
HEIGHT = 820
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === initialize
|
28
|
+
# ========================================================================= #
|
29
|
+
def initialize(
|
30
|
+
run_already = true
|
31
|
+
)
|
32
|
+
reset
|
33
|
+
run if run_already
|
34
|
+
end
|
35
|
+
|
36
|
+
# ========================================================================= #
|
37
|
+
# === reset (reset tag)
|
38
|
+
# ========================================================================= #
|
39
|
+
def reset
|
40
|
+
reset_the_shared_module if respond_to?(:reset_the_shared_module)
|
41
|
+
end
|
42
|
+
|
43
|
+
# ========================================================================= #
|
44
|
+
# === run
|
45
|
+
# ========================================================================= #
|
46
|
+
def run
|
47
|
+
frame = frame('Showcasing JEditorPane')
|
48
|
+
panel = new_panel # This is an instance of Java::JavaxSwing::JPanel.
|
49
|
+
panel.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
50
|
+
frame.getContentPane.add(panel)
|
51
|
+
panel.box_layout
|
52
|
+
|
53
|
+
panel.hint = 'A quit button example'
|
54
|
+
editor_pane = JEditorPane.new
|
55
|
+
# editor_pane.readonly
|
56
|
+
editor_pane.set_size(820, 600)
|
57
|
+
editor_pane.use_this_font = :hack_32
|
58
|
+
|
59
|
+
# ======================================================================= #
|
60
|
+
# Put the editor pane in a scroll pane.
|
61
|
+
# ======================================================================= #
|
62
|
+
scroll_pane = scroll_pane(editor_pane)
|
63
|
+
scroll_pane.vertical_scrollbar_always
|
64
|
+
scroll_pane.min_size(820, 700)
|
65
|
+
|
66
|
+
panel << editor_pane
|
67
|
+
panel << quit_button
|
68
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
69
|
+
frame.exit_on_close
|
70
|
+
frame.set_size(WIDTH, HEIGHT)
|
71
|
+
frame.setLocationRelativeTo(nil)
|
72
|
+
frame.show_all
|
73
|
+
end
|
74
|
+
|
75
|
+
end; end
|
76
|
+
|
77
|
+
if __FILE__ == $PROGRAM_NAME
|
78
|
+
SwingParadise::Prototype.new
|
79
|
+
end
|