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,38 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import java.awt.Frame
|
4
|
+
|
5
|
+
class SimpleBoxExample < Frame
|
6
|
+
|
7
|
+
require 'swing_paradise/base_module/base_module.rb'
|
8
|
+
include SwingParadise::BaseModule
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === initialize
|
12
|
+
# ========================================================================= #
|
13
|
+
def initialize
|
14
|
+
super('SimpleBoxExample Example')
|
15
|
+
set_size(480, 180)
|
16
|
+
panel = new_boxlayout(:new_panel)
|
17
|
+
# panel.set_font(Font.new('Calibri', Font::PLAIN, 42))
|
18
|
+
panel.setBorder(
|
19
|
+
BorderFactory.createEmptyBorder(10, 10, 10, 10)
|
20
|
+
)
|
21
|
+
|
22
|
+
box = create_hbox
|
23
|
+
box.add(create_text('OK'))
|
24
|
+
box.add(
|
25
|
+
ImageIcon.new(
|
26
|
+
'/home/x/data/images/NJOY/Susanne_01.jpg'
|
27
|
+
)
|
28
|
+
)
|
29
|
+
|
30
|
+
panel.batch_add(box)
|
31
|
+
add(panel, BorderLayout::NORTH)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
if __FILE__ == $PROGRAM_NAME
|
37
|
+
SimpleBoxExample.new.is_visible
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import java.awt.Frame
|
4
|
+
|
5
|
+
class FrameExample < Frame
|
6
|
+
|
7
|
+
require 'swing_paradise/base_module/base_module.rb'
|
8
|
+
include SwingParadise::BaseModule
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === initialize
|
12
|
+
# ========================================================================= #
|
13
|
+
def initialize
|
14
|
+
super('014 mouse events example')
|
15
|
+
set_size(480, 180)
|
16
|
+
panel = JPanel.new(GridLayout.new(7, 1, 5, 5))
|
17
|
+
panel.use_this_font = :calibri_62
|
18
|
+
panel.uniform_border(20)
|
19
|
+
|
20
|
+
_ = BorderFactory.createTitledBorder(" Frame")
|
21
|
+
panel.setBorder(_)
|
22
|
+
panel.mouse_listener {|event| # Java::JavaAwtEvent::MouseEvent
|
23
|
+
if left_mouse_click?(event)
|
24
|
+
e 'The left mouse button was clicked.'
|
25
|
+
elsif middle_mouse_click?(event)
|
26
|
+
e 'The middle mouse button was clicked.'
|
27
|
+
elsif right_mouse_click?(event)
|
28
|
+
e 'The right mouse button was clicked.'
|
29
|
+
end
|
30
|
+
}
|
31
|
+
_ = bold_text('Mouse events example')
|
32
|
+
_.complex_font(:hack_35)
|
33
|
+
panel.add(_, JLabel::CENTER)
|
34
|
+
add(panel, BorderLayout::NORTH)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
if __FILE__ == $PROGRAM_NAME
|
40
|
+
FrameExample.new.is_visible
|
41
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import javax.swing.JFrame
|
4
|
+
|
5
|
+
module SwingParadise
|
6
|
+
|
7
|
+
class QuitButtonExample < JFrame
|
8
|
+
|
9
|
+
require 'swing_paradise'
|
10
|
+
include SwingParadise::BaseModule
|
11
|
+
|
12
|
+
require 'colours/html_colours'
|
13
|
+
include ::Colours::HtmlColours
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === initialize
|
17
|
+
# ========================================================================= #
|
18
|
+
def initialize(
|
19
|
+
run_already = true
|
20
|
+
)
|
21
|
+
run if run_already
|
22
|
+
end
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === run
|
26
|
+
# ========================================================================= #
|
27
|
+
def run
|
28
|
+
frame = frame('A menu example')
|
29
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
30
|
+
panel.use_this_font = :hack_85
|
31
|
+
frame.getContentPane.add(panel)
|
32
|
+
panel.setLayout(nil)
|
33
|
+
panel.hint = 'A quit button example'
|
34
|
+
_ = quit_button
|
35
|
+
_.set_bounds(10, 20, 200, 40)
|
36
|
+
panel << _
|
37
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
38
|
+
frame.exit_on_close
|
39
|
+
frame.set_size(500, 400)
|
40
|
+
frame.setLocationRelativeTo(nil)
|
41
|
+
|
42
|
+
menu_bar = create_menubar # Create a new menubar here.
|
43
|
+
m1 = JMenu.new('General options') # The first menu.
|
44
|
+
menu_bar << m1
|
45
|
+
m2 = JMenu.new('Help') # The second menu.
|
46
|
+
m2.setEnabled(false)
|
47
|
+
menu_bar << m2
|
48
|
+
|
49
|
+
# Create the menu items and add them to the menus
|
50
|
+
first = menu_item('Entry #1')
|
51
|
+
second = menu_item('Entry #2')
|
52
|
+
third = menu_item('Entry #3')
|
53
|
+
fourth = menu_item('Entry #4')
|
54
|
+
fifth = menu_item('Entry #5')
|
55
|
+
m1 << first
|
56
|
+
m1 << (second)
|
57
|
+
m1 << (third)
|
58
|
+
m1 << (fourth)
|
59
|
+
m1 << (fifth)
|
60
|
+
first.addActionListener {|event|
|
61
|
+
e 'The first menu has been activated.'
|
62
|
+
action_command = event.get_action_command
|
63
|
+
e 'The action command - aka the label - was: '+
|
64
|
+
steelblue(action_command)
|
65
|
+
first.setText(action_command+'_') # This just shows how to change the text.
|
66
|
+
}
|
67
|
+
|
68
|
+
frame.menubar = menu_bar
|
69
|
+
frame.use_this_font = :hack_30
|
70
|
+
frame.show_all
|
71
|
+
end
|
72
|
+
|
73
|
+
end; end
|
74
|
+
|
75
|
+
if __FILE__ == $PROGRAM_NAME
|
76
|
+
SwingParadise::QuitButtonExample.new
|
77
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import javax.swing.JFrame
|
4
|
+
|
5
|
+
module SwingParadise
|
6
|
+
|
7
|
+
class QuitButtonExample < JFrame
|
8
|
+
|
9
|
+
require 'swing_paradise'
|
10
|
+
include SwingParadise::BaseModule
|
11
|
+
|
12
|
+
require 'colours/html_colours'
|
13
|
+
include ::Colours::HtmlColours
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === initialize
|
17
|
+
# ========================================================================= #
|
18
|
+
def initialize(
|
19
|
+
run_already = true
|
20
|
+
)
|
21
|
+
run if run_already
|
22
|
+
end
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === do_choose_a_local_file
|
26
|
+
# ========================================================================= #
|
27
|
+
def do_choose_a_local_file
|
28
|
+
file_chooser = create_file_chooser
|
29
|
+
result = file_chooser.open_the_dialog
|
30
|
+
case result
|
31
|
+
when JFileChooser::APPROVE_OPTION
|
32
|
+
this_file = file_chooser.getSelectedFile.getAbsoluteFile.to_s
|
33
|
+
this_file = File.absolute_path(this_file)
|
34
|
+
e steelblue(this_file)
|
35
|
+
end
|
36
|
+
return file_chooser
|
37
|
+
end
|
38
|
+
|
39
|
+
# ========================================================================= #
|
40
|
+
# === run
|
41
|
+
# ========================================================================= #
|
42
|
+
def run
|
43
|
+
frame = frame('A file chooser example')
|
44
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
45
|
+
panel.use_this_font = :hack_85
|
46
|
+
frame.getContentPane.add(panel)
|
47
|
+
panel.setLayout(nil)
|
48
|
+
panel.hint = 'A quit button example'
|
49
|
+
_ = button('Pick a local file')
|
50
|
+
_.set_bounds(10, 20, 200, 40)
|
51
|
+
panel << _
|
52
|
+
_.on_clicked {
|
53
|
+
do_choose_a_local_file
|
54
|
+
}
|
55
|
+
|
56
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
57
|
+
frame.exit_on_close
|
58
|
+
frame.set_size(500, 400)
|
59
|
+
frame.setLocationRelativeTo(nil)
|
60
|
+
|
61
|
+
menu_bar = create_menubar # Create a new menubar here.
|
62
|
+
m1 = JMenu.new('General options') # The first menu.
|
63
|
+
menu_bar << m1
|
64
|
+
m2 = JMenu.new('Help') # The second menu.
|
65
|
+
m2.setEnabled(false)
|
66
|
+
menu_bar << m2
|
67
|
+
|
68
|
+
# Create the menu items and add them to the menus
|
69
|
+
first = menu_item('Entry #1')
|
70
|
+
second = menu_item('Entry #2')
|
71
|
+
third = menu_item('Entry #3')
|
72
|
+
fourth = menu_item('Entry #4')
|
73
|
+
fifth = menu_item('Entry #5')
|
74
|
+
m1 << first
|
75
|
+
m1 << (second)
|
76
|
+
m1 << (third)
|
77
|
+
m1 << (fourth)
|
78
|
+
m1 << (fifth)
|
79
|
+
first.addActionListener {|event|
|
80
|
+
e 'The first menu has been activated.'
|
81
|
+
action_command = event.get_action_command
|
82
|
+
e 'The action command - aka the label - was: '+
|
83
|
+
steelblue(action_command)
|
84
|
+
first.setText(action_command+'_') # This just shows how to change the text.
|
85
|
+
}
|
86
|
+
|
87
|
+
frame.menubar = menu_bar
|
88
|
+
frame.use_this_font = :hack_30
|
89
|
+
frame.show_all
|
90
|
+
end
|
91
|
+
|
92
|
+
end; end
|
93
|
+
|
94
|
+
if __FILE__ == $PROGRAM_NAME
|
95
|
+
SwingParadise::QuitButtonExample.new
|
96
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
|
9
|
+
module SwingParadise
|
10
|
+
|
11
|
+
class ButtonsExample < JFrame
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include SwingParadise::BaseModule
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === initialize
|
18
|
+
# ========================================================================= #
|
19
|
+
def initialize(
|
20
|
+
run_already = true
|
21
|
+
)
|
22
|
+
run if run_already
|
23
|
+
end
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === run
|
27
|
+
# ========================================================================= #
|
28
|
+
def run
|
29
|
+
frame = frame('A quit button example')
|
30
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
31
|
+
panel.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
32
|
+
frame.getContentPane.add(panel)
|
33
|
+
panel.setLayout(FlowLayout.new)
|
34
|
+
panel.hint = 'A quit button example'
|
35
|
+
_ = quit_button
|
36
|
+
_.set_bounds(10, 20, 200, 40)
|
37
|
+
panel << _
|
38
|
+
button1 = create_button('Button #1 (click via Alt+h)')
|
39
|
+
button1.on_clicked {
|
40
|
+
e 'button1 was clicked.'
|
41
|
+
}
|
42
|
+
button1.setMnemonic(KeyEvent::VK_H)
|
43
|
+
button1.hint = 'Press Alt+H to trigger this button.'
|
44
|
+
panel << button1
|
45
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
46
|
+
frame.exit_on_close
|
47
|
+
frame.set_size(500, 400)
|
48
|
+
frame.setLocationRelativeTo(nil)
|
49
|
+
frame.show_all
|
50
|
+
end
|
51
|
+
|
52
|
+
end; end
|
53
|
+
|
54
|
+
if __FILE__ == $PROGRAM_NAME
|
55
|
+
SwingParadise::ButtonsExample.new
|
56
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
|
9
|
+
module SwingParadise
|
10
|
+
|
11
|
+
class ColourChooserExample < JFrame
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include SwingParadise::BaseModule
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === initialize
|
18
|
+
# ========================================================================= #
|
19
|
+
def initialize(
|
20
|
+
run_already = true
|
21
|
+
)
|
22
|
+
run if run_already
|
23
|
+
end
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === run
|
27
|
+
# ========================================================================= #
|
28
|
+
def run
|
29
|
+
frame = frame('A quit button example')
|
30
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
31
|
+
panel.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
32
|
+
frame.getContentPane.add(panel)
|
33
|
+
panel.setLayout(FlowLayout.new)
|
34
|
+
panel.hint = 'A quit button example'
|
35
|
+
_ = quit_button
|
36
|
+
_.set_bounds(10, 20, 200, 40)
|
37
|
+
panel << _
|
38
|
+
colorchooser = JColorChooser.new
|
39
|
+
panel << colorchooser
|
40
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
41
|
+
frame.exit_on_close
|
42
|
+
frame.set_size(800, 500)
|
43
|
+
frame.setLocationRelativeTo(nil)
|
44
|
+
frame.show_all
|
45
|
+
end
|
46
|
+
|
47
|
+
end; end
|
48
|
+
|
49
|
+
if __FILE__ == $PROGRAM_NAME
|
50
|
+
SwingParadise::ColourChooserExample.new
|
51
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
|
9
|
+
module SwingParadise
|
10
|
+
|
11
|
+
class JeditorpaneExample < JFrame
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include SwingParadise::BaseModule
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === initialize
|
18
|
+
# ========================================================================= #
|
19
|
+
def initialize(
|
20
|
+
run_already = true
|
21
|
+
)
|
22
|
+
run if run_already
|
23
|
+
end
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === run
|
27
|
+
# ========================================================================= #
|
28
|
+
def run
|
29
|
+
frame = frame('Showcasing JEditorPane')
|
30
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
31
|
+
panel.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
32
|
+
frame.getContentPane.add(panel)
|
33
|
+
panel.setLayout(BoxLayout.new(panel, BoxLayout::PAGE_AXIS)) # FlowLayout.new)
|
34
|
+
|
35
|
+
panel.hint = 'A quit button example'
|
36
|
+
editor_pane = JEditorPane.new
|
37
|
+
# editor_pane.readonly
|
38
|
+
editor_pane.set_size(820, 600)
|
39
|
+
editor_pane.use_this_font = :hack_32
|
40
|
+
|
41
|
+
# ======================================================================= #
|
42
|
+
# Put the editor pane in a scroll pane.
|
43
|
+
# ======================================================================= #
|
44
|
+
scroll_pane = scroll_pane(editor_pane)
|
45
|
+
scroll_pane.vertical_scrollbar_always
|
46
|
+
scroll_pane.min_size(820, 700)
|
47
|
+
|
48
|
+
panel << editor_pane
|
49
|
+
panel << quit_button
|
50
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
51
|
+
frame.exit_on_close
|
52
|
+
frame.set_size(1250, 500)
|
53
|
+
frame.setLocationRelativeTo(nil)
|
54
|
+
frame.show_all
|
55
|
+
end
|
56
|
+
|
57
|
+
end; end
|
58
|
+
|
59
|
+
if __FILE__ == $PROGRAM_NAME
|
60
|
+
SwingParadise::JeditorpaneExample.new
|
61
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
|
9
|
+
module SwingParadise
|
10
|
+
|
11
|
+
class TableExample < JFrame
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include SwingParadise::BaseModule
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === EVEN_ROW_COLOR
|
18
|
+
# ========================================================================= #
|
19
|
+
EVEN_ROW_COLOR = Color.new(241, 245, 250)
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === TABLE_GRID_COLOR
|
23
|
+
# ========================================================================= #
|
24
|
+
TABLE_GRID_COLOR = Color.new(0xd9d9d9)
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === initialize
|
28
|
+
# ========================================================================= #
|
29
|
+
def initialize(
|
30
|
+
run_already = true
|
31
|
+
)
|
32
|
+
run if run_already
|
33
|
+
end
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === run
|
37
|
+
# ========================================================================= #
|
38
|
+
def run
|
39
|
+
frame = frame('Showcasing JEditorPane')
|
40
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
41
|
+
panel.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
42
|
+
frame.getContentPane.add(panel)
|
43
|
+
panel.setLayout(BoxLayout.new(panel, BoxLayout::PAGE_AXIS)) # FlowLayout.new)
|
44
|
+
panel.hint = 'Table example'
|
45
|
+
|
46
|
+
m = defaul_table_model
|
47
|
+
m.add_column('id')
|
48
|
+
m.add_column('name')
|
49
|
+
m.add_row(['1', 'jimmy'].to_java)
|
50
|
+
m.add_row(['2', 'robert'].to_java)
|
51
|
+
|
52
|
+
table = JTable.new(m)
|
53
|
+
table.use_this_font = :mono_18
|
54
|
+
|
55
|
+
# ======================================================================= #
|
56
|
+
# Put the editor pane in a scroll pane.
|
57
|
+
# ======================================================================= #
|
58
|
+
scroll_pane = scroll_pane(table)
|
59
|
+
scroll_pane.vertical_scrollbar_always
|
60
|
+
scroll_pane.min_size(820, 700)
|
61
|
+
#scroll_pane.use_this_font = :hack_30
|
62
|
+
|
63
|
+
panel << scroll_pane
|
64
|
+
panel << quit_button
|
65
|
+
|
66
|
+
frame.set_font(Font.new 'Sans serif', Font::PLAIN, 85)
|
67
|
+
frame.exit_on_close
|
68
|
+
frame.set_size(1250, 500)
|
69
|
+
frame.setLocationRelativeTo(nil)
|
70
|
+
frame.show_all
|
71
|
+
end
|
72
|
+
|
73
|
+
end; end
|
74
|
+
|
75
|
+
if __FILE__ == $PROGRAM_NAME
|
76
|
+
SwingParadise::TableExample.new
|
77
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
|
9
|
+
module SwingParadise
|
10
|
+
|
11
|
+
class JSplitPaneExample < JFrame
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include SwingParadise::BaseModule
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === initialize
|
18
|
+
# ========================================================================= #
|
19
|
+
def initialize(
|
20
|
+
run_already = true
|
21
|
+
)
|
22
|
+
run if run_already
|
23
|
+
end
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === run
|
27
|
+
# ========================================================================= #
|
28
|
+
def run
|
29
|
+
frame = frame('Showcasing JEditorPane')
|
30
|
+
panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
|
31
|
+
panel.use_this_font = :hack_40
|
32
|
+
frame.getContentPane.add(panel)
|
33
|
+
panel.setLayout(BoxLayout.new(panel, BoxLayout::PAGE_AXIS)) # FlowLayout.new)
|
34
|
+
panel.hint = 'Table example'
|
35
|
+
|
36
|
+
split_pane = JSplitPane.new(JSplitPane::VERTICAL_SPLIT)
|
37
|
+
split_pane.setContinuousLayout(true)
|
38
|
+
split_pane.setOneTouchExpandable(true)
|
39
|
+
button_on_top = JButton.new('A')
|
40
|
+
split_pane.setTopComponent(button_on_top)
|
41
|
+
button_on_bottom =JButton.new('B')
|
42
|
+
split_pane.setBottomComponent(button_on_bottom)
|
43
|
+
|
44
|
+
# ======================================================================= #
|
45
|
+
# Put the editor pane in a scroll pane.
|
46
|
+
# ======================================================================= #
|
47
|
+
scroll_pane = scroll_pane(split_pane)
|
48
|
+
scroll_pane.vertical_scrollbar_always
|
49
|
+
scroll_pane.min_size(820, 700)
|
50
|
+
#scroll_pane.use_this_font = :hack_40
|
51
|
+
|
52
|
+
panel << scroll_pane
|
53
|
+
panel << quit_button
|
54
|
+
|
55
|
+
frame.use_this_font = :hack_50
|
56
|
+
frame.exit_on_close
|
57
|
+
frame.set_size(1250, 500)
|
58
|
+
frame.setLocationRelativeTo(nil)
|
59
|
+
frame.show_all
|
60
|
+
end
|
61
|
+
|
62
|
+
end; end
|
63
|
+
|
64
|
+
if __FILE__ == $PROGRAM_NAME
|
65
|
+
SwingParadise::JSplitPaneExample.new
|
66
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
java_import javax.swing.JPanel
|
9
|
+
java_import java.awt.Dimension
|
10
|
+
|
11
|
+
class DrawingOvalExample < JPanel
|
12
|
+
|
13
|
+
require 'swing_paradise'
|
14
|
+
include SwingParadise::BaseModule
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === initialize
|
18
|
+
# ========================================================================= #
|
19
|
+
def initialize(
|
20
|
+
run_already = true
|
21
|
+
)
|
22
|
+
super()
|
23
|
+
run if run_already
|
24
|
+
end
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === paintComponent
|
28
|
+
# ========================================================================= #
|
29
|
+
def paintComponent(graphics)
|
30
|
+
1000.times { |entry|
|
31
|
+
x = Math.sin(entry) + 1
|
32
|
+
y = Math.cos(entry * 0.2) + 1
|
33
|
+
graphics.draw_oval(x * 320, y * 240, 10, 10)
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# ========================================================================= #
|
38
|
+
# === run
|
39
|
+
# ========================================================================= #
|
40
|
+
def run
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
if __FILE__ == $PROGRAM_NAME
|
46
|
+
frame = JFrame.new 'Hello, JRuby!'
|
47
|
+
frame.size = Dimension.new(640, 480)
|
48
|
+
panel = DrawingOvalExample.new
|
49
|
+
frame.add panel
|
50
|
+
frame.visible = true
|
51
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# The idea for this .rb file is to showcase what can be done with
|
3
|
+
# buttons in jruby-swing.
|
4
|
+
# =========================================================================== #
|
5
|
+
include Java
|
6
|
+
|
7
|
+
java_import javax.swing.JFrame
|
8
|
+
|
9
|
+
class ShowMessageDialogExample < JFrame
|
10
|
+
|
11
|
+
require 'swing_paradise/base_module/base_module.rb'
|
12
|
+
include SwingParadise::BaseModule
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === TITLE
|
16
|
+
# ========================================================================= #
|
17
|
+
TITLE = 'Show Message Dialog Example'
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === initialize
|
21
|
+
# ========================================================================= #
|
22
|
+
def initialize(
|
23
|
+
run_already = true
|
24
|
+
)
|
25
|
+
super('FrameExample Example')
|
26
|
+
set_size(480, 180)
|
27
|
+
run if run_already
|
28
|
+
end
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === run
|
32
|
+
# ========================================================================= #
|
33
|
+
def run
|
34
|
+
message_dialog = JOptionPane.showMessageDialog(
|
35
|
+
Component parent,
|
36
|
+
TITLE, # String title,
|
37
|
+
String message,
|
38
|
+
int type
|
39
|
+
)
|
40
|
+
panel = JPanel.new(GridLayout.new(7, 1, 5, 5))
|
41
|
+
panel.set_font(Font.new('Calibri', Font::PLAIN, 62))
|
42
|
+
panel.setBorder(
|
43
|
+
BorderFactory.uniform_border(20)
|
44
|
+
)
|
45
|
+
_ = BorderFactory.createTitledBorder(" Frame")
|
46
|
+
panel.setBorder(_)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
if __FILE__ == $PROGRAM_NAME
|
52
|
+
frame = JFrame.new 'Hello, JRuby!'
|
53
|
+
frame.size = Dimension.new(640, 480)
|
54
|
+
panel = ShowMessageDialogExample.new
|
55
|
+
frame.add panel
|
56
|
+
frame.visible = true
|
57
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# === Java::JavaxSwing::BorderFactory
|
3
|
+
# =========================================================================== #
|
4
|
+
# require 'swing_paradise/java_classes/border_factory/border_factory.rb'
|
5
|
+
# =========================================================================== #
|
6
|
+
# javax.swing.BorderFactory
|
7
|
+
# =========================================================================== #
|
8
|
+
class Java::JavaxSwing::BorderFactory
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === BorderFactory.create_uniform_empty_border
|
12
|
+
# ========================================================================= #
|
13
|
+
def self.create_uniform_empty_border(
|
14
|
+
i = 1
|
15
|
+
)
|
16
|
+
createEmptyBorder(i, i, i, i)
|
17
|
+
end; self.instance_eval { alias uniform_border create_uniform_empty_border } # === BorderFactory.uniform_border
|
18
|
+
|
19
|
+
end
|