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,319 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jframe/jframe.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
class Java::JavaxSwing::JFrame
|
5
|
+
|
6
|
+
java_import java.awt.Dimension
|
7
|
+
|
8
|
+
# ========================================================================= #
|
9
|
+
# === menubar
|
10
|
+
# ========================================================================= #
|
11
|
+
def menubar(i = nil)
|
12
|
+
setJMenuBar(i) if i
|
13
|
+
end
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === set_size_request
|
17
|
+
# ========================================================================= #
|
18
|
+
def set_size_request(
|
19
|
+
height = 680,
|
20
|
+
widt = 480
|
21
|
+
)
|
22
|
+
setSize(height.to_i, width.to_i)
|
23
|
+
end
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === menubar=
|
27
|
+
# ========================================================================= #
|
28
|
+
def menubar=(i)
|
29
|
+
setJMenuBar(i)
|
30
|
+
end
|
31
|
+
|
32
|
+
# ========================================================================= #
|
33
|
+
# === set_default_size
|
34
|
+
# ========================================================================= #
|
35
|
+
def set_default_size(
|
36
|
+
width = 820,
|
37
|
+
height = 620
|
38
|
+
)
|
39
|
+
setSize(width, height)
|
40
|
+
setPreferredSize(
|
41
|
+
java.awt.Dimension.new(width, height)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
# ========================================================================= #
|
46
|
+
# === use_this_font=
|
47
|
+
# ========================================================================= #
|
48
|
+
def use_this_font=(i)
|
49
|
+
i = SwingParadise.jruby_font(i)
|
50
|
+
setFont(i)
|
51
|
+
end
|
52
|
+
|
53
|
+
# ========================================================================= #
|
54
|
+
# === <<
|
55
|
+
# ========================================================================= #
|
56
|
+
alias << add
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === maximize
|
60
|
+
# ========================================================================= #
|
61
|
+
def maximize
|
62
|
+
setVisible(true)
|
63
|
+
setExtendedState(JFrame::MAXIMIZED_BOTH)
|
64
|
+
end
|
65
|
+
|
66
|
+
# ========================================================================= #
|
67
|
+
# === has_the_enter_key_been_pressed?
|
68
|
+
#
|
69
|
+
# This method assumes that a java-swing event was passed as argument.
|
70
|
+
# ========================================================================= #
|
71
|
+
def has_the_enter_key_been_pressed?(event)
|
72
|
+
event.getKeyCode == KeyEvent::VK_ESCAPE
|
73
|
+
end
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === allow_the_escape_key_to_exit
|
77
|
+
# ========================================================================= #
|
78
|
+
def allow_the_escape_key_to_exit(&block)
|
79
|
+
add_key_listener {|event|
|
80
|
+
if has_the_enter_key_been_pressed?(event)
|
81
|
+
System.exit(0)
|
82
|
+
end
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
# ========================================================================= #
|
87
|
+
# === set_padding
|
88
|
+
#
|
89
|
+
# This is currently ignored - not sure how to properly set it for java
|
90
|
+
# swing.
|
91
|
+
# ========================================================================= #
|
92
|
+
def set_padding(
|
93
|
+
i = 0
|
94
|
+
)
|
95
|
+
i = i.to_i
|
96
|
+
getRootPane.setBorder(
|
97
|
+
BorderFactory.createEmptyBorder(i, i, i, i)
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
# ========================================================================= #
|
102
|
+
# === set_border_size
|
103
|
+
# ========================================================================= #
|
104
|
+
def set_border_size(
|
105
|
+
i = 0,
|
106
|
+
use_this_colour = Color::BLACK # Or Color::RED and so forth.
|
107
|
+
)
|
108
|
+
i = i.to_i
|
109
|
+
getRootPane.setBorder(
|
110
|
+
BorderFactory.createMatteBorder(i, i, i, i, use_this_colour)
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
# ========================================================================= #
|
115
|
+
# === add_north
|
116
|
+
# ========================================================================= #
|
117
|
+
def add_north(widget)
|
118
|
+
getContentPane.add(widget, BorderLayout::NORTH)
|
119
|
+
end
|
120
|
+
|
121
|
+
# ========================================================================= #
|
122
|
+
# === add_south
|
123
|
+
# ========================================================================= #
|
124
|
+
def add_south(widget)
|
125
|
+
getContentPane.add(widget, BorderLayout::SOUTH)
|
126
|
+
end
|
127
|
+
|
128
|
+
# ========================================================================= #
|
129
|
+
# === add_west
|
130
|
+
# ========================================================================= #
|
131
|
+
def add_west(widget)
|
132
|
+
getContentPane.add(widget, BorderLayout::WEST)
|
133
|
+
end
|
134
|
+
|
135
|
+
# ========================================================================= #
|
136
|
+
# === add_east
|
137
|
+
# ========================================================================= #
|
138
|
+
def add_east(widget)
|
139
|
+
getContentPane.add(widget, BorderLayout::EAST)
|
140
|
+
end
|
141
|
+
|
142
|
+
# ========================================================================= #
|
143
|
+
# === add_center
|
144
|
+
# ========================================================================= #
|
145
|
+
def add_center(widget)
|
146
|
+
getContentPane.add(widget, BorderLayout::CENTER)
|
147
|
+
end
|
148
|
+
|
149
|
+
# ========================================================================= #
|
150
|
+
# === font_size
|
151
|
+
#
|
152
|
+
# The font constants in regards to font-style are:
|
153
|
+
#
|
154
|
+
# [:BOLD, :CENTER_BASELINE, :DIALOG, :DIALOG_INPUT, :HANGING_BASELINE,
|
155
|
+
# :ITALIC, :LAYOUT_LEFT_TO_RIGHT, :LAYOUT_NO_LIMIT_CONTEXT,
|
156
|
+
# :LAYOUT_NO_START_CONTEXT,:LAYOUT_RIGHT_TO_LEFT,:MONOSPACED,:PLAIN,
|
157
|
+
# :ROMAN_BASELINE, :SANS_SERIF, :SERIF, :TRUETYPE_FONT, :TYPE1_FONT]
|
158
|
+
#
|
159
|
+
# ========================================================================= #
|
160
|
+
def font_size(
|
161
|
+
new_size = 30,
|
162
|
+
font_family_to_use = 'SansSerif'
|
163
|
+
)
|
164
|
+
new_size = new_size.to_f
|
165
|
+
font = java.awt.Font.new(font_family_to_use, Font::PLAIN, new_size)
|
166
|
+
setFont(font)
|
167
|
+
end
|
168
|
+
|
169
|
+
# ========================================================================= #
|
170
|
+
# === top_left
|
171
|
+
# ========================================================================= #
|
172
|
+
def top_left
|
173
|
+
setLocation(0, 0)
|
174
|
+
end
|
175
|
+
|
176
|
+
# ========================================================================= #
|
177
|
+
# === width_height=
|
178
|
+
# ========================================================================= #
|
179
|
+
def width_height=(
|
180
|
+
width,
|
181
|
+
height = nil
|
182
|
+
)
|
183
|
+
if width.is_a? Array
|
184
|
+
height = width.last
|
185
|
+
width = width.first
|
186
|
+
end
|
187
|
+
setSize(width, height)
|
188
|
+
end
|
189
|
+
|
190
|
+
# ========================================================================= #
|
191
|
+
# === is_resizable
|
192
|
+
# ========================================================================= #
|
193
|
+
def is_resizable
|
194
|
+
JFrame.setResizable(true)
|
195
|
+
end
|
196
|
+
|
197
|
+
# ========================================================================= #
|
198
|
+
# === is_not_resizable
|
199
|
+
# ========================================================================= #
|
200
|
+
def is_not_resizable
|
201
|
+
JFrame.setResizable(false)
|
202
|
+
end
|
203
|
+
|
204
|
+
# ========================================================================= #
|
205
|
+
# === set_width
|
206
|
+
# ========================================================================= #
|
207
|
+
def set_width(i)
|
208
|
+
i = i.to_i
|
209
|
+
setPreferredSize(
|
210
|
+
java.awt.Dimension.new(i, -1)
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
# ========================================================================= #
|
215
|
+
# === show_all
|
216
|
+
# ========================================================================= #
|
217
|
+
def show_all
|
218
|
+
setVisible(true)
|
219
|
+
end
|
220
|
+
|
221
|
+
# ========================================================================= #
|
222
|
+
# === width_height
|
223
|
+
# ========================================================================= #
|
224
|
+
def width_height(
|
225
|
+
width = 1024,
|
226
|
+
height = 800
|
227
|
+
)
|
228
|
+
if width.is_a? String # This can be like this: '62% or minimum 300px'
|
229
|
+
if width.include? 'px'
|
230
|
+
scanned = width.scan(/(\d{1,}px)/)
|
231
|
+
width = scanned.flatten.first.delete('px')
|
232
|
+
end
|
233
|
+
end
|
234
|
+
if height.is_a? String # This can be like this: '62% or minimum 300px'
|
235
|
+
if height.include? 'px'
|
236
|
+
height = height.scan(/\d{1,}px/).flatten.first.delete('px')
|
237
|
+
end
|
238
|
+
end
|
239
|
+
if width.is_a? Hash and width.has_key?(:height)
|
240
|
+
height = width.delete(:height)
|
241
|
+
end
|
242
|
+
if width.is_a? Hash and width.has_key?(:width)
|
243
|
+
width = width.delete(:width)
|
244
|
+
end
|
245
|
+
width = width.to_i
|
246
|
+
height = height.to_i
|
247
|
+
setSize(width, height)
|
248
|
+
# The next variant does not appear to work that well:
|
249
|
+
# setPreferredSize(Dimension.new(width, height))
|
250
|
+
end
|
251
|
+
|
252
|
+
# ========================================================================= #
|
253
|
+
# === exit_on_close
|
254
|
+
# ========================================================================= #
|
255
|
+
def exit_on_close
|
256
|
+
setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
|
257
|
+
end
|
258
|
+
|
259
|
+
# ========================================================================= #
|
260
|
+
# === is_decorated
|
261
|
+
# ========================================================================= #
|
262
|
+
def is_decorated
|
263
|
+
setDefaultLookAndFeelDecorated(true)
|
264
|
+
end
|
265
|
+
|
266
|
+
# ========================================================================= #
|
267
|
+
# === complex_font
|
268
|
+
#
|
269
|
+
# This is a convenience wrapper over .set_font().
|
270
|
+
#
|
271
|
+
# You only have to pass the first argument really; the other three
|
272
|
+
# arguments are not so important, as the first argument may override
|
273
|
+
# them automatically.
|
274
|
+
# ========================================================================= #
|
275
|
+
def complex_font(
|
276
|
+
i = 'Calibri 34',
|
277
|
+
use_this_font_name = 'Times',
|
278
|
+
use_this_font_size = 20,
|
279
|
+
use_this_font_type = Font::PLAIN
|
280
|
+
)
|
281
|
+
# ======================================================================= #
|
282
|
+
# === Handle Symbols first
|
283
|
+
# ======================================================================= #
|
284
|
+
if i.is_a? Symbol
|
285
|
+
if i.to_s.include? '_'
|
286
|
+
splitted = i.to_s.split('_')
|
287
|
+
use_this_font_size = splitted.last.to_i
|
288
|
+
use_this_font_name = splitted.first.to_s
|
289
|
+
i = ''
|
290
|
+
end
|
291
|
+
end
|
292
|
+
if i.respond_to?(:include?) and i.include?(' ')
|
293
|
+
splitted = i.split(' ')
|
294
|
+
first = splitted.first
|
295
|
+
last = splitted.last
|
296
|
+
if last =~ /^\d+$/ # If "only numbers".
|
297
|
+
use_this_font_size = last.to_i
|
298
|
+
end
|
299
|
+
if first
|
300
|
+
use_this_font_name = first
|
301
|
+
end
|
302
|
+
end
|
303
|
+
if i.is_a? Java::JavaAwt::Font
|
304
|
+
set_font(i)
|
305
|
+
else
|
306
|
+
set_font(
|
307
|
+
Font.new(
|
308
|
+
first,
|
309
|
+
use_this_font_type,
|
310
|
+
use_this_font_size
|
311
|
+
)
|
312
|
+
)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def pad8px
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jlabel/jlabel.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
class Java::JavaxSwing::JLabel
|
5
|
+
|
6
|
+
alias original_set_font set_font # === original_set_font
|
7
|
+
|
8
|
+
# ========================================================================= #
|
9
|
+
# === original_set_text
|
10
|
+
# ========================================================================= #
|
11
|
+
alias original_set_text setText
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === set_markup
|
15
|
+
# ========================================================================= #
|
16
|
+
def set_markup(
|
17
|
+
i = '',
|
18
|
+
optional_boolen_value = true
|
19
|
+
)
|
20
|
+
set_text(i)
|
21
|
+
end
|
22
|
+
|
23
|
+
# ========================================================================= #
|
24
|
+
# === set_text
|
25
|
+
# ========================================================================= #
|
26
|
+
def set_text(i)
|
27
|
+
# i = PdfParadise.remove_html(i)
|
28
|
+
original_set_text(i)
|
29
|
+
end
|
30
|
+
|
31
|
+
# ========================================================================= #
|
32
|
+
# === set_font
|
33
|
+
# ========================================================================= #
|
34
|
+
def set_font(i = :hack_25)
|
35
|
+
original_set_font(
|
36
|
+
SwingParadise.jruby_font(i)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# ========================================================================= #
|
41
|
+
# === set_font_size
|
42
|
+
#
|
43
|
+
# This is based on upstream java code such as:
|
44
|
+
#
|
45
|
+
# label.setFont (label.getFont ().deriveFont (64.0f))
|
46
|
+
#
|
47
|
+
# ========================================================================= #
|
48
|
+
def set_font_size(i)
|
49
|
+
setFont(
|
50
|
+
getFont.deriveFont(i.to_f)
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
# ========================================================================= #
|
55
|
+
# === use_this_font=
|
56
|
+
# ========================================================================= #
|
57
|
+
alias use_this_font= setFont
|
58
|
+
|
59
|
+
# ========================================================================= #
|
60
|
+
# === center
|
61
|
+
# ========================================================================= #
|
62
|
+
def center
|
63
|
+
setAlignmentX(Component::CENTER_ALIGNMENT)
|
64
|
+
end
|
65
|
+
|
66
|
+
# ========================================================================= #
|
67
|
+
# === to_the_left
|
68
|
+
#
|
69
|
+
# This method will align the label on the left-hand side.
|
70
|
+
# ========================================================================= #
|
71
|
+
def to_the_left
|
72
|
+
setAlignmentX(Component::LEFT_ALIGNMENT)
|
73
|
+
end
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === dimensions
|
77
|
+
#
|
78
|
+
# This is just a wrapper over setBounds() to allow us to work with
|
79
|
+
# a Hash instead.
|
80
|
+
# ========================================================================= #
|
81
|
+
def dimensions(
|
82
|
+
hash = {
|
83
|
+
x_axis: 10,
|
84
|
+
y_axis: 20,
|
85
|
+
width: 300,
|
86
|
+
height: 50
|
87
|
+
}
|
88
|
+
)
|
89
|
+
# is: x-coordinate, y-coordinate, width, height)
|
90
|
+
setBounds(
|
91
|
+
hash[:x_axis],
|
92
|
+
hash[:y_axis],
|
93
|
+
hash[:width],
|
94
|
+
hash[:height]
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
# ========================================================================= #
|
99
|
+
# === make_bold
|
100
|
+
# ========================================================================= #
|
101
|
+
def make_bold
|
102
|
+
bold_font = Font.new(getFont.getName, Font::BOLD, getFont.getSize)
|
103
|
+
setFont(bold_font)
|
104
|
+
end
|
105
|
+
|
106
|
+
# ========================================================================= #
|
107
|
+
# === text?
|
108
|
+
# ========================================================================= #
|
109
|
+
def text?
|
110
|
+
getText.to_s
|
111
|
+
end
|
112
|
+
|
113
|
+
# ========================================================================= #
|
114
|
+
# Past this point we will have entries that are stubs.
|
115
|
+
# ========================================================================= #
|
116
|
+
|
117
|
+
# ========================================================================= #
|
118
|
+
# === do_markify
|
119
|
+
# ========================================================================= #
|
120
|
+
def do_markify
|
121
|
+
end
|
122
|
+
|
123
|
+
# ========================================================================= #
|
124
|
+
# === make_selectable
|
125
|
+
# ========================================================================= #
|
126
|
+
def make_selectable
|
127
|
+
end
|
128
|
+
|
129
|
+
# ========================================================================= #
|
130
|
+
# === bblack2
|
131
|
+
# ========================================================================= #
|
132
|
+
def bblack2
|
133
|
+
end
|
134
|
+
|
135
|
+
# ========================================================================= #
|
136
|
+
# === yellow_background
|
137
|
+
# ========================================================================= #
|
138
|
+
def yellow_background
|
139
|
+
end
|
140
|
+
|
141
|
+
# ========================================================================= #
|
142
|
+
# === hint=
|
143
|
+
# ========================================================================= #
|
144
|
+
def hint=(i = '')
|
145
|
+
end
|
146
|
+
|
147
|
+
# ========================================================================= #
|
148
|
+
# === pad8px
|
149
|
+
# ========================================================================= #
|
150
|
+
def pad8px
|
151
|
+
end
|
152
|
+
|
153
|
+
# ========================================================================= #
|
154
|
+
# === enable_all_events
|
155
|
+
# ========================================================================= #
|
156
|
+
def enable_all_events
|
157
|
+
end
|
158
|
+
|
159
|
+
# ========================================================================= #
|
160
|
+
# === on_enter
|
161
|
+
# ========================================================================= #
|
162
|
+
def on_enter
|
163
|
+
end
|
164
|
+
|
165
|
+
# ========================================================================= #
|
166
|
+
# === signal_connect
|
167
|
+
# ========================================================================= #
|
168
|
+
def signal_connect(i = '')
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jmenu/jmenu.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
# javax.swing.JMenu
|
5
|
+
# =========================================================================== #
|
6
|
+
class Java::JavaxSwing::JMenu
|
7
|
+
|
8
|
+
# ========================================================================= #
|
9
|
+
# === <<
|
10
|
+
# ========================================================================= #
|
11
|
+
alias << add
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jmenubar/jmenubar.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
# javax.swing.JMenuBar
|
5
|
+
# =========================================================================== #
|
6
|
+
class Java::JavaxSwing::JMenuBar
|
7
|
+
|
8
|
+
# ========================================================================= #
|
9
|
+
# === <<
|
10
|
+
# ========================================================================= #
|
11
|
+
alias << add
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'swing_paradise/java_classes/jpanel/jpanel.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
java_import java.awt.Font
|
5
|
+
|
6
|
+
class Java::JavaxSwing::JPanel
|
7
|
+
|
8
|
+
# ========================================================================= #
|
9
|
+
# === hint=
|
10
|
+
#
|
11
|
+
# Enable: panel.hint=
|
12
|
+
# ========================================================================= #
|
13
|
+
alias hint= setToolTipText
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# Add << as alias to .add() next:
|
17
|
+
# ========================================================================= #
|
18
|
+
alias << add
|
19
|
+
|
20
|
+
# ========================================================================= #
|
21
|
+
# === box_layout
|
22
|
+
# ========================================================================= #
|
23
|
+
def box_layout
|
24
|
+
setLayout(
|
25
|
+
BoxLayout.new(self, BoxLayout::PAGE_AXIS)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# ========================================================================= #
|
30
|
+
# === uniform_border
|
31
|
+
# ========================================================================= #
|
32
|
+
def uniform_border(i = 20)
|
33
|
+
set_border(
|
34
|
+
BorderFactory.uniform_border(i)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === add_all
|
40
|
+
# ========================================================================= #
|
41
|
+
def add_all(*i)
|
42
|
+
i.flatten.each {|this_widget|
|
43
|
+
add(this_widget)
|
44
|
+
}
|
45
|
+
end; alias batch_add add_all # === batch_add
|
46
|
+
|
47
|
+
# ========================================================================= #
|
48
|
+
# === no_layout
|
49
|
+
# ========================================================================= #
|
50
|
+
def no_layout
|
51
|
+
setLayout(nil)
|
52
|
+
end
|
53
|
+
|
54
|
+
# ========================================================================= #
|
55
|
+
# === dimensions
|
56
|
+
#
|
57
|
+
# This is just a wrapper over setBounds() to allow us to work with
|
58
|
+
# a Hash instead.
|
59
|
+
# ========================================================================= #
|
60
|
+
def dimensions(
|
61
|
+
hash = {
|
62
|
+
x_axis: 10,
|
63
|
+
y_axis: 20,
|
64
|
+
width: 300,
|
65
|
+
height: 50
|
66
|
+
}
|
67
|
+
)
|
68
|
+
# is: x-coordinate, y-coordinate, width, height)
|
69
|
+
setBounds(
|
70
|
+
hash[:x_axis],
|
71
|
+
hash[:y_axis],
|
72
|
+
hash[:width],
|
73
|
+
hash[:height]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# ========================================================================= #
|
78
|
+
# === set_column_spacing
|
79
|
+
#
|
80
|
+
# This is currently not in use.
|
81
|
+
# ========================================================================= #
|
82
|
+
def set_column_spacing(i = 2)
|
83
|
+
end
|
84
|
+
|
85
|
+
# ========================================================================= #
|
86
|
+
# === set_row_spacing
|
87
|
+
#
|
88
|
+
# This is currently not in use.
|
89
|
+
# ========================================================================= #
|
90
|
+
def set_row_spacing(i = 2)
|
91
|
+
end
|
92
|
+
|
93
|
+
# ========================================================================= #
|
94
|
+
# === font=
|
95
|
+
#
|
96
|
+
# This could be invoked like so:
|
97
|
+
#
|
98
|
+
# panel.font = :sans_serif_25
|
99
|
+
#
|
100
|
+
# It presently does not work, though.
|
101
|
+
# ========================================================================= #
|
102
|
+
# def font=(i)
|
103
|
+
# font_to_use = 'Sans serif'
|
104
|
+
# font_variant = Font::PLAIN # Font is actually Java::JavaAwt::Font
|
105
|
+
# font_size = 25
|
106
|
+
# if i.is_a? Symbol
|
107
|
+
# splitted = i.to_s.tr('_',' ').split(' ')
|
108
|
+
# font_size = splitted.pop
|
109
|
+
# font_to_use = splitted.join(' ')
|
110
|
+
# font_to_use[0, 1] = font_to_use[0, 1].upcase
|
111
|
+
# end
|
112
|
+
# set_font(Font.new(font_to_use), font_variant, font_size)
|
113
|
+
# end
|
114
|
+
|
115
|
+
end
|