swing_paradise 0.1.46
Sign up to get free protection for your applications and to get access to all the features.
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,15 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/requires/require_the_project.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
require 'swing_paradise/toplevel_methods/misc.rb'
|
5
|
+
require 'swing_paradise/java_classes/jbutton/jbutton.rb'
|
6
|
+
require 'swing_paradise/java_classes/jframe/jframe.rb'
|
7
|
+
require 'swing_paradise/java_classes/jlabel/jlabel.rb'
|
8
|
+
require 'swing_paradise/java_classes/jpanel/jpanel.rb'
|
9
|
+
require 'swing_paradise/java_classes/jspinner/jspinner.rb'
|
10
|
+
require 'swing_paradise/java_classes/jtextfield/jtextfield.rb'
|
11
|
+
require 'swing_paradise/java_classes/jtextarea/jtextarea.rb'
|
12
|
+
require 'swing_paradise/java_classes/jcombobox/jcombobox.rb'
|
13
|
+
require 'swing_paradise/java_classes/jscrollpane/jscrollpane.rb'
|
14
|
+
require 'swing_paradise/misc/misc.rb'
|
15
|
+
require 'swing_paradise/base_module/base_module.rb'
|
@@ -0,0 +1,293 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'swing_paradise/toplevel_methods/misc.rb'
|
6
|
+
# include SwingParadise
|
7
|
+
# =========================================================================== #
|
8
|
+
module SwingParadise
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === SwingParadise.set_global_font
|
12
|
+
# ========================================================================= #
|
13
|
+
def self.set_global_font(
|
14
|
+
font1 = Font.new('Hack', Font::PLAIN, 50)
|
15
|
+
)
|
16
|
+
UIManager.put('Button.font', font1)
|
17
|
+
UIManager.put('ToggleButton.font', font1)
|
18
|
+
UIManager.put('RadioButton.font', font1)
|
19
|
+
UIManager.put('CheckBox.font', font1)
|
20
|
+
UIManager.put('ColorChooser.font', font1)
|
21
|
+
UIManager.put('ComboBox.font', font1)
|
22
|
+
UIManager.put('Label.font', font1)
|
23
|
+
UIManager.put('List.font', font1)
|
24
|
+
UIManager.put('MenuBar.font', font1)
|
25
|
+
UIManager.put('MenuItem.font', font1)
|
26
|
+
UIManager.put('RadioButtonMenuItem.font', font1)
|
27
|
+
UIManager.put('CheckBoxMenuItem.font', font1)
|
28
|
+
UIManager.put('Menu.font', font1)
|
29
|
+
UIManager.put('PopupMenu.font', font1)
|
30
|
+
UIManager.put('OptionPane.font', font1)
|
31
|
+
UIManager.put('Panel.font', font1)
|
32
|
+
UIManager.put('ProgressBar.font', font1)
|
33
|
+
UIManager.put('ScrollPane.font', font1)
|
34
|
+
UIManager.put('Viewport.font', font1)
|
35
|
+
UIManager.put('TabbedPane.font', font1)
|
36
|
+
UIManager.put('Table.font', font1)
|
37
|
+
UIManager.put('TableHeader.font', font1)
|
38
|
+
UIManager.put('TextField.font', font1)
|
39
|
+
UIManager.put('PasswordField.font', font1)
|
40
|
+
UIManager.put('TextArea.font', font1)
|
41
|
+
UIManager.put('TextPane.font', font1)
|
42
|
+
UIManager.put('EditorPane.font', font1)
|
43
|
+
UIManager.put('TitledBorder.font', font1)
|
44
|
+
UIManager.put('ToolBar.font', font1)
|
45
|
+
UIManager.put('ToolTip.font', font1)
|
46
|
+
UIManager.put('Tree.font', font1)
|
47
|
+
end
|
48
|
+
|
49
|
+
# ========================================================================= #
|
50
|
+
# === SwingParadise.create_text_view
|
51
|
+
# ========================================================================= #
|
52
|
+
def self.create_text_view
|
53
|
+
return JTextArea.new
|
54
|
+
end
|
55
|
+
|
56
|
+
# ========================================================================= #
|
57
|
+
# === SwingParadise.is_left_mouse_button?
|
58
|
+
# ========================================================================= #
|
59
|
+
def self.is_left_mouse_button?(event)
|
60
|
+
javax.swing.SwingUtilities.isLeftMouseButton(event)
|
61
|
+
end
|
62
|
+
|
63
|
+
# ========================================================================= #
|
64
|
+
# === SwingParadise.create_image
|
65
|
+
#
|
66
|
+
# We can not use ImageIcon directly because this can then not be
|
67
|
+
# .add()-ed to a box, so we need to use a label, and then use
|
68
|
+
# .setIcon() on it instead.
|
69
|
+
# ========================================================================= #
|
70
|
+
def self.create_image(i)
|
71
|
+
label = JLabel.new
|
72
|
+
image_icon = ImageIcon.new(i)
|
73
|
+
label.setIcon(image_icon)
|
74
|
+
return label
|
75
|
+
end
|
76
|
+
|
77
|
+
# ========================================================================= #
|
78
|
+
# === SwingParadise.jruby_font
|
79
|
+
#
|
80
|
+
# This method should be equivalent to:
|
81
|
+
#
|
82
|
+
# Font.new('Sans serif', Font::PLAIN, 28)
|
83
|
+
#
|
84
|
+
# It must also be able to deal with Symbols, such as :hack_25.
|
85
|
+
#
|
86
|
+
# Usage example:
|
87
|
+
#
|
88
|
+
# LARGE_FONT = SwingParadise.jruby_font('Sans serif 28')
|
89
|
+
#
|
90
|
+
# ========================================================================= #
|
91
|
+
def self.jruby_font(
|
92
|
+
i = 'Sans serif 28',
|
93
|
+
type_variant = Font::PLAIN, # This is the default font type to be used.
|
94
|
+
font_size = 20
|
95
|
+
)
|
96
|
+
name_of_the_font = 'Sans serif'
|
97
|
+
if i.is_a? Symbol # Handle Symbols first.
|
98
|
+
splitted = i.to_s.split('_') # :hack_20 would now be ['hack','20'].
|
99
|
+
font_size = splitted.last.to_i # ['hack','20']
|
100
|
+
name_of_the_font = splitted.first.capitalize
|
101
|
+
i = nil # Short-circuit it here.
|
102
|
+
end
|
103
|
+
if i and i.respond_to?(:include?) and i.include?(' ')
|
104
|
+
splitted = i.split(' ') # i = 'Monospace 25'; splitted = i.split(' ')
|
105
|
+
font_size = splitted.last.to_i
|
106
|
+
name_of_the_font = splitted[0 .. -2].join(' ')
|
107
|
+
else
|
108
|
+
name_of_the_font = i
|
109
|
+
end
|
110
|
+
if i.is_a? Java::JavaAwt::Font
|
111
|
+
return i
|
112
|
+
end
|
113
|
+
return Font.new(name_of_the_font, type_variant, font_size)
|
114
|
+
end; self.instance_eval { alias font jruby_font } # === SwingParadise.font
|
115
|
+
self.instance_eval { alias convert_font jruby_font } # === SwingParadise.convert_font
|
116
|
+
|
117
|
+
# ========================================================================= #
|
118
|
+
# === SwingParadise.button
|
119
|
+
# ========================================================================= #
|
120
|
+
def self.button(i = '')
|
121
|
+
require 'swing_paradise/java_classes/jbutton/jbutton.rb'
|
122
|
+
_ = javax.swing.JButton.new(i)
|
123
|
+
return _
|
124
|
+
end; self.instance_eval { alias create_button button } # === SwingParadise.create_button
|
125
|
+
|
126
|
+
# ========================================================================= #
|
127
|
+
# === quit_button
|
128
|
+
#
|
129
|
+
# This method can be used to quickly create a quit-button.
|
130
|
+
# ========================================================================= #
|
131
|
+
def quit_button
|
132
|
+
_ = SwingParadise.button('Quit')
|
133
|
+
_.on_event {|event|
|
134
|
+
System.exit(0)
|
135
|
+
}
|
136
|
+
return _
|
137
|
+
end
|
138
|
+
|
139
|
+
# ========================================================================= #
|
140
|
+
# === SwingParadise.jscroll_pane
|
141
|
+
#
|
142
|
+
# A JScrollPane provides a scrollable view of another widget. The
|
143
|
+
# JScrollPane manages a viewport, optional vertical and horizontal
|
144
|
+
# scroll bars, and optional row and column heading viewports.
|
145
|
+
# ========================================================================= #
|
146
|
+
def self.jscroll_pane(
|
147
|
+
child_widget,
|
148
|
+
vertical_scrollbar_policy = :vertical_always,
|
149
|
+
horizontal_scrollbar_policy = :default
|
150
|
+
)
|
151
|
+
case vertical_scrollbar_policy
|
152
|
+
# ======================================================================= #
|
153
|
+
# === :vertical_always
|
154
|
+
# ======================================================================= #
|
155
|
+
when :vertical_always
|
156
|
+
vertical_scrollbar_policy = Java::JavaxSwing::ScrollPaneConstants::VERTICAL_SCROLLBAR_ALWAYS
|
157
|
+
end
|
158
|
+
case horizontal_scrollbar_policy
|
159
|
+
# ======================================================================= #
|
160
|
+
# === :default
|
161
|
+
# ======================================================================= #
|
162
|
+
when :default
|
163
|
+
horizontal_scrollbar_policy = Java::JavaxSwing::ScrollPaneConstants::HORIZONTAL_SCROLLBAR_ALWAYS
|
164
|
+
# ======================================================================= #
|
165
|
+
# === :horizontal_never
|
166
|
+
# ======================================================================= #
|
167
|
+
when :horizontal_never
|
168
|
+
horizontal_scrollbar_policy = Java::JavaxSwing::ScrollPaneConstants::HORIZONTAL_SCROLLBAR_NEVER
|
169
|
+
end
|
170
|
+
JScrollPane.new(
|
171
|
+
child_widget,
|
172
|
+
vertical_scrollbar_policy,
|
173
|
+
horizontal_scrollbar_policy
|
174
|
+
)
|
175
|
+
end; self.instance_eval { alias scroll_pane jscroll_pane } # === SwingParadise.scroll_pane
|
176
|
+
self.instance_eval { alias scrollpane jscroll_pane } # === SwingParadise.scrollpane
|
177
|
+
self.instance_eval { alias scrolled_window jscroll_pane } # === SwingParadise.scrolled_window
|
178
|
+
self.instance_eval { alias scrolling jscroll_pane } # === SwingParadise.scrolling
|
179
|
+
self.instance_eval { alias created_scrolled_window jscroll_pane } # === SwingParadise.created_scrolled_window
|
180
|
+
self.instance_eval { alias create_scrolled_window jscroll_pane } # === SwingParadise.create_scrolled_window
|
181
|
+
|
182
|
+
# ========================================================================= #
|
183
|
+
# === SwingParadise.entry
|
184
|
+
#
|
185
|
+
# Java Swing has two basic text components:
|
186
|
+
#
|
187
|
+
# (1) JTextField, and
|
188
|
+
# (2) JTextArea
|
189
|
+
#
|
190
|
+
# ========================================================================= #
|
191
|
+
def self.entry(
|
192
|
+
i = '',
|
193
|
+
optional_n_entries = nil
|
194
|
+
)
|
195
|
+
# require 'swing_paradise/java_classes/jtextarea/jtextarea.rb'
|
196
|
+
require 'swing_paradise/java_classes/jtextfield/jtextfield.rb'
|
197
|
+
if optional_n_entries
|
198
|
+
_ = javax.swing.JTextField.new(i, optional_n_entries) # JTextArea.new(i)
|
199
|
+
else
|
200
|
+
_ = javax.swing.JTextField.new(i) # JTextArea.new(i)
|
201
|
+
end
|
202
|
+
return _
|
203
|
+
end; self.instance_eval { alias create_entry entry } # === SwingParadise.create_entry
|
204
|
+
|
205
|
+
# ========================================================================= #
|
206
|
+
# === SwingParadise.vbox
|
207
|
+
#
|
208
|
+
# A vertical box.
|
209
|
+
# ========================================================================= #
|
210
|
+
def self.vbox
|
211
|
+
javax.swing.Box.createVerticalBox
|
212
|
+
end; self.instance_eval { alias create_vbox vbox } # === SwingParadise.create_vbox
|
213
|
+
|
214
|
+
# ========================================================================= #
|
215
|
+
# === SwingParadise.hbox
|
216
|
+
#
|
217
|
+
# A horizontal box.
|
218
|
+
# ========================================================================= #
|
219
|
+
def self.hbox(*optional_widgets)
|
220
|
+
optional_widgets.flatten!
|
221
|
+
_ = javax.swing.Box.createHorizontalBox
|
222
|
+
if optional_widgets and !optional_widgets.empty?
|
223
|
+
optional_widgets.each {|this_widget|
|
224
|
+
_.add(this_widget)
|
225
|
+
}
|
226
|
+
end
|
227
|
+
return _
|
228
|
+
end; self.instance_eval { alias create_hbox hbox } # === SwingParadise.create_hbox
|
229
|
+
|
230
|
+
# ========================================================================= #
|
231
|
+
# === SwingParadise.remove_html
|
232
|
+
#
|
233
|
+
# Usage example:
|
234
|
+
#
|
235
|
+
# SwingParadise.remove_html('<one>two</three>')
|
236
|
+
#
|
237
|
+
# ========================================================================= #
|
238
|
+
def self.remove_html(i)
|
239
|
+
i.gsub(
|
240
|
+
%r{<[^>]+>},
|
241
|
+
''
|
242
|
+
)
|
243
|
+
end
|
244
|
+
|
245
|
+
# ========================================================================= #
|
246
|
+
# === SwingParadise.text
|
247
|
+
#
|
248
|
+
# This method will return a JLabel instance.
|
249
|
+
# ========================================================================= #
|
250
|
+
def self.text(i = '')
|
251
|
+
_ = javax.swing.JLabel.new(i)
|
252
|
+
return _
|
253
|
+
end; self.instance_eval { alias label text } # === SwingParadise.label
|
254
|
+
|
255
|
+
# ========================================================================= #
|
256
|
+
# === swing_dimension
|
257
|
+
#
|
258
|
+
# This is a slight wrapper over java.awt.Dimension.
|
259
|
+
# ========================================================================= #
|
260
|
+
def swing_dimension(new_width, new_height)
|
261
|
+
java.awt.Dimension.new(new_width, new_height)
|
262
|
+
end
|
263
|
+
|
264
|
+
# ========================================================================= #
|
265
|
+
# === jcombobox
|
266
|
+
# ========================================================================= #
|
267
|
+
def jcombobox(i = nil)
|
268
|
+
combo_box = JComboBox.new
|
269
|
+
if i and i.respond_to?(:each)
|
270
|
+
i.each {|this_exam_topic|
|
271
|
+
combo_box.addItem(this_exam_topic)
|
272
|
+
}
|
273
|
+
end
|
274
|
+
return combo_box
|
275
|
+
end
|
276
|
+
|
277
|
+
# ========================================================================= #
|
278
|
+
# === text
|
279
|
+
# ========================================================================= #
|
280
|
+
def text(i = '')
|
281
|
+
return JLabel.new(i)
|
282
|
+
end; alias jtext text # === jtext
|
283
|
+
|
284
|
+
# ========================================================================= #
|
285
|
+
# === show_message_dialog
|
286
|
+
# ========================================================================= #
|
287
|
+
def show_message_dialog(
|
288
|
+
text = ''
|
289
|
+
)
|
290
|
+
javax.swing.JOptionPane.showMessageDialog(nil, text)
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module SwingParadise
|
6
|
+
|
7
|
+
# ========================================================================= #
|
8
|
+
# === VERSION
|
9
|
+
# ========================================================================= #
|
10
|
+
VERSION = '0.1.46'
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === LAST_UPDATE
|
14
|
+
# ========================================================================= #
|
15
|
+
LAST_UDPATE = '11.04.2024'
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === TextViewer
|
6
|
+
#
|
7
|
+
# Usage example:
|
8
|
+
#
|
9
|
+
# TextViewer.new(ARGV)
|
10
|
+
#
|
11
|
+
# =========================================================================== #
|
12
|
+
# require 'text_viewer.rb'
|
13
|
+
# =========================================================================== #
|
14
|
+
require 'swing_paradise/base_module/base_module.rb'
|
15
|
+
|
16
|
+
module SwingParadise
|
17
|
+
|
18
|
+
class TextViewer < JFrame # === SwingParadise::TextViewer
|
19
|
+
|
20
|
+
include ::SwingParadise::BaseModule
|
21
|
+
|
22
|
+
# ========================================================================= #
|
23
|
+
# === WIDTH
|
24
|
+
# ========================================================================= #
|
25
|
+
WIDTH = 1400
|
26
|
+
|
27
|
+
# ========================================================================= #
|
28
|
+
# === HEIGHT
|
29
|
+
# ========================================================================= #
|
30
|
+
HEIGHT = 1024
|
31
|
+
|
32
|
+
# ========================================================================= #
|
33
|
+
# === initialize
|
34
|
+
# ========================================================================= #
|
35
|
+
def initialize(
|
36
|
+
commandline_arguments = nil,
|
37
|
+
run_already = true
|
38
|
+
)
|
39
|
+
super()
|
40
|
+
reset
|
41
|
+
set_commandline_arguments(
|
42
|
+
commandline_arguments
|
43
|
+
)
|
44
|
+
run if run_already
|
45
|
+
end
|
46
|
+
|
47
|
+
# ========================================================================= #
|
48
|
+
# === reset (reset tag)
|
49
|
+
# ========================================================================= #
|
50
|
+
def reset
|
51
|
+
super() if respond_to?(:super)
|
52
|
+
# infer_the_namespace
|
53
|
+
end
|
54
|
+
|
55
|
+
# ========================================================================= #
|
56
|
+
# === create_the_menu (menu tag)
|
57
|
+
# ========================================================================= #
|
58
|
+
def create_the_menu
|
59
|
+
@menu_bar = create_menu_bar
|
60
|
+
m1 = JMenu.new('Open a local file')
|
61
|
+
m1.use_this_font = :hack_28
|
62
|
+
m1.setMnemonic(KeyEvent::VK_A)
|
63
|
+
|
64
|
+
open_a_local_file_entrypoint = JMenuItem.new('Open a local file', KeyEvent::VK_T)
|
65
|
+
open_a_local_file_entrypoint.use_this_font = :hack_26
|
66
|
+
open_a_local_file_entrypoint.addActionListener {|event|
|
67
|
+
do_choose_a_local_file_then_read_it_in
|
68
|
+
}
|
69
|
+
m1 << open_a_local_file_entrypoint
|
70
|
+
|
71
|
+
@menu_bar << m1
|
72
|
+
m2 = JMenu.new('Help')
|
73
|
+
m2.use_this_font = :hack_28
|
74
|
+
@menu_bar.add(m2)
|
75
|
+
@menu_bar.use_this_font = :hack_30
|
76
|
+
end
|
77
|
+
|
78
|
+
# ========================================================================= #
|
79
|
+
# === run (run tag)
|
80
|
+
# ========================================================================= #
|
81
|
+
def run
|
82
|
+
create_the_menu
|
83
|
+
|
84
|
+
frame = frame('Viewing the content of a file:')
|
85
|
+
panel = create_panel # This is an instance of Java::JavaxSwing::JPanel.
|
86
|
+
panel.use_this_font = :hack_40
|
87
|
+
frame << panel
|
88
|
+
panel.setLayout(BoxLayout.new(panel, BoxLayout::PAGE_AXIS)) # FlowLayout.new)
|
89
|
+
panel.hint = 'Table example'
|
90
|
+
|
91
|
+
# ======================================================================= #
|
92
|
+
# Put the editor pane in a scroll pane.
|
93
|
+
# ======================================================================= #
|
94
|
+
button1 = create_button
|
95
|
+
@text_view = create_text_view
|
96
|
+
@text_view.use_this_font = :hack_30
|
97
|
+
scroll_pane = scroll_pane(@text_view)
|
98
|
+
scroll_pane.vertical_scrollbar_always
|
99
|
+
scroll_pane.min_size(WIDTH, HEIGHT)
|
100
|
+
scroll_pane.pad10px
|
101
|
+
panel << scroll_pane
|
102
|
+
qbutton = quit_button # quit tag
|
103
|
+
qbutton.use_this_font = :hack_32
|
104
|
+
panel << qbutton
|
105
|
+
|
106
|
+
frame.menubar(@menu_bar)
|
107
|
+
frame.use_this_font = :hack_30
|
108
|
+
frame.exit_on_close
|
109
|
+
frame.set_size(WIDTH+100, 800)
|
110
|
+
frame.setLocationRelativeTo(nil)
|
111
|
+
check_commandline_arguments
|
112
|
+
frame.show_all
|
113
|
+
end
|
114
|
+
|
115
|
+
# ========================================================================= #
|
116
|
+
# === do_choose_a_local_file_then_read_it_in
|
117
|
+
# ========================================================================= #
|
118
|
+
def do_choose_a_local_file_then_read_it_in
|
119
|
+
file_chooser = JFileChooser.new # dialog tag.
|
120
|
+
file_chooser.use_this_font = :hack_38
|
121
|
+
# file_chooser.setFileSelectionMode(JFileChooser::DIRECTORIES_ONLY)
|
122
|
+
result = file_chooser.showOpenDialog(nil)
|
123
|
+
case result
|
124
|
+
when JFileChooser::APPROVE_OPTION
|
125
|
+
this_file = file_chooser.getSelectedFile.getAbsoluteFile.to_s
|
126
|
+
this_file = File.absolute_path(this_file)
|
127
|
+
read_in_this_file(this_file)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# ========================================================================= #
|
132
|
+
# === read_in_this_file
|
133
|
+
# ========================================================================= #
|
134
|
+
def read_in_this_file(i)
|
135
|
+
@text_view.set_text(File.read(i))
|
136
|
+
end
|
137
|
+
|
138
|
+
# ========================================================================= #
|
139
|
+
# === check_commandline_arguments
|
140
|
+
# ========================================================================= #
|
141
|
+
def check_commandline_arguments
|
142
|
+
commandline_arguments?.each {|entry|
|
143
|
+
if entry and File.file?(entry)
|
144
|
+
read_in_this_file(entry)
|
145
|
+
end
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
# ========================================================================= #
|
150
|
+
# === TextViewer[]
|
151
|
+
# ========================================================================= #
|
152
|
+
def self.[](i = '')
|
153
|
+
new(i)
|
154
|
+
end
|
155
|
+
|
156
|
+
end; end
|
157
|
+
|
158
|
+
if __FILE__ == $PROGRAM_NAME
|
159
|
+
SwingParadise::TextViewer.new(ARGV)
|
160
|
+
end # text_viewer.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'swing_paradise/requires/require_the_project.rb'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'yaml'
|
6
|
+
require 'swing_paradise/version/version.rb'
|
7
|
+
require 'roebe'
|
8
|
+
|
9
|
+
Gem::Specification.new { |s|
|
10
|
+
|
11
|
+
s.name = 'swing_paradise'
|
12
|
+
s.version = SwingParadise::VERSION
|
13
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
14
|
+
|
15
|
+
DESCRIPTION = <<-EOF
|
16
|
+
|
17
|
+
This gem is meant to be for jruby only.
|
18
|
+
|
19
|
+
It attempts to make the Swing bindings, available in Java,
|
20
|
+
more convenient to use from within Ruby code. In other
|
21
|
+
words: this gem is basically a helper-wrapper over Swing.
|
22
|
+
Naturally you need to use jruby, if you wish to make use
|
23
|
+
of this gem.
|
24
|
+
|
25
|
+
EOF
|
26
|
+
|
27
|
+
s.summary = DESCRIPTION
|
28
|
+
s.description = DESCRIPTION
|
29
|
+
|
30
|
+
s.authors = ['Robert A. Heiler']
|
31
|
+
s.email = Roebe.email?
|
32
|
+
s.files = Dir['**/*']
|
33
|
+
|
34
|
+
s.license = 'MIT'
|
35
|
+
s.homepage = 'https://www.rubydoc.info/gems/rbt/'
|
36
|
+
s.require_paths = ['lib']
|
37
|
+
|
38
|
+
s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
|
39
|
+
s.required_rubygems_version = '>= '+Gem::VERSION
|
40
|
+
s.rubygems_version = '>= '+Gem::VERSION
|
41
|
+
|
42
|
+
}
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swing_paradise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.46
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert A. Heiler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-04-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2+
|
14
|
+
|
15
|
+
This gem is meant to be for jruby only.
|
16
|
+
|
17
|
+
It attempts to make the Swing bindings, available in Java,
|
18
|
+
more convenient to use from within Ruby code. In other
|
19
|
+
words: this gem is basically a helper-wrapper over Swing.
|
20
|
+
Naturally you need to use jruby, if you wish to make use
|
21
|
+
of this gem.
|
22
|
+
|
23
|
+
email: shevy@inbox.lt
|
24
|
+
executables: []
|
25
|
+
extensions: []
|
26
|
+
extra_rdoc_files: []
|
27
|
+
files:
|
28
|
+
- README.md
|
29
|
+
- doc/README.gen
|
30
|
+
- lib/swing_paradise.rb
|
31
|
+
- lib/swing_paradise/autoinclude.rb
|
32
|
+
- lib/swing_paradise/awt/README.md
|
33
|
+
- lib/swing_paradise/awt/color.rb
|
34
|
+
- lib/swing_paradise/base_module/base_module.rb
|
35
|
+
- lib/swing_paradise/classes
|
36
|
+
- lib/swing_paradise/examples/001_quit_button_example.rb
|
37
|
+
- lib/swing_paradise/examples/002_text_area_example.rb
|
38
|
+
- lib/swing_paradise/examples/003_combo_box_example.rb
|
39
|
+
- lib/swing_paradise/examples/004_jpanel_left_bound_example.rb
|
40
|
+
- lib/swing_paradise/examples/005_box_layout_example.rb
|
41
|
+
- lib/swing_paradise/examples/006_frame_example.rb
|
42
|
+
- lib/swing_paradise/examples/007_textarea_responding_to_enter_key_example.rb
|
43
|
+
- lib/swing_paradise/examples/008_scrolled_window_example.rb
|
44
|
+
- lib/swing_paradise/examples/009_font_size_example.rb
|
45
|
+
- lib/swing_paradise/examples/010_counter_example.rb
|
46
|
+
- lib/swing_paradise/examples/011_button_with_image_example.rb
|
47
|
+
- lib/swing_paradise/examples/012_quit_on_escape_key_being_pressed.rb
|
48
|
+
- lib/swing_paradise/examples/013_simple_box_example.rb
|
49
|
+
- lib/swing_paradise/examples/014_mouse_events_example.rb
|
50
|
+
- lib/swing_paradise/examples/015_menu_example.rb
|
51
|
+
- lib/swing_paradise/examples/016_file_chooser_example.rb
|
52
|
+
- lib/swing_paradise/examples/017_buttons_example.rb
|
53
|
+
- lib/swing_paradise/examples/018_colour_chooser_example.rb
|
54
|
+
- lib/swing_paradise/examples/019_jeditorpane_example.rb
|
55
|
+
- lib/swing_paradise/examples/020_table_example.rb
|
56
|
+
- lib/swing_paradise/examples/021_jsplitpane_example.rb
|
57
|
+
- lib/swing_paradise/examples/022_drawing_oval_example.rb
|
58
|
+
- lib/swing_paradise/examples/023_show_message_dialog_example.rb
|
59
|
+
- lib/swing_paradise/java_classes/border_factory/border_factory.rb
|
60
|
+
- lib/swing_paradise/java_classes/box/box.rb
|
61
|
+
- lib/swing_paradise/java_classes/button
|
62
|
+
- lib/swing_paradise/java_classes/checkbox
|
63
|
+
- lib/swing_paradise/java_classes/combobox
|
64
|
+
- lib/swing_paradise/java_classes/default_table_model/default_table_model.rb
|
65
|
+
- lib/swing_paradise/java_classes/frame
|
66
|
+
- lib/swing_paradise/java_classes/jbutton/jbutton.rb
|
67
|
+
- lib/swing_paradise/java_classes/jcheckbox/jcheckbox.rb
|
68
|
+
- lib/swing_paradise/java_classes/jcombobox/jcombobox.rb
|
69
|
+
- lib/swing_paradise/java_classes/jcomponent/jcomponent.rb
|
70
|
+
- lib/swing_paradise/java_classes/jeditorpane/jeditorpane.rb
|
71
|
+
- lib/swing_paradise/java_classes/jfilechooser/jfilechooser.rb
|
72
|
+
- lib/swing_paradise/java_classes/jframe/jframe.rb
|
73
|
+
- lib/swing_paradise/java_classes/jlabel/jlabel.rb
|
74
|
+
- lib/swing_paradise/java_classes/jmenu/jmenu.rb
|
75
|
+
- lib/swing_paradise/java_classes/jmenubar/jmenubar.rb
|
76
|
+
- lib/swing_paradise/java_classes/jpanel/jpanel.rb
|
77
|
+
- lib/swing_paradise/java_classes/jscrollpane/jscrollpane.rb
|
78
|
+
- lib/swing_paradise/java_classes/jspinner/jspinner.rb
|
79
|
+
- lib/swing_paradise/java_classes/jtextarea/jtextarea.rb
|
80
|
+
- lib/swing_paradise/java_classes/jtextfield/jtextfield.rb
|
81
|
+
- lib/swing_paradise/java_classes/label
|
82
|
+
- lib/swing_paradise/java_classes/panel
|
83
|
+
- lib/swing_paradise/java_classes/spinner
|
84
|
+
- lib/swing_paradise/java_classes/textarea
|
85
|
+
- lib/swing_paradise/misc/misc.rb
|
86
|
+
- lib/swing_paradise/prototype/prototype.rb
|
87
|
+
- lib/swing_paradise/requires/require_the_project.rb
|
88
|
+
- lib/swing_paradise/toplevel_methods/misc.rb
|
89
|
+
- lib/swing_paradise/version/version.rb
|
90
|
+
- lib/swing_paradise/widget_collection/README.md
|
91
|
+
- lib/swing_paradise/widget_collection/text_viewer.rb
|
92
|
+
- swing_paradise.gemspec
|
93
|
+
homepage: https://www.rubydoc.info/gems/rbt/
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 2.7.6
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.5.7
|
111
|
+
requirements: []
|
112
|
+
rubygems_version: 3.5.7
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: 'This gem is meant to be for jruby only. It attempts to make the Swing bindings,
|
116
|
+
available in Java, more convenient to use from within Ruby code. In other words:
|
117
|
+
this gem is basically a helper-wrapper over Swing. Naturally you need to use jruby,
|
118
|
+
if you wish to make use of this gem.'
|
119
|
+
test_files: []
|
120
|
+
...
|