swing_paradise 0.0.15

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0fde3c447e09283a11f783c60e85864db52904733b980bd82f426690d6465118
4
+ data.tar.gz: 47e4b6fdf29fc5ab13c5b6d454861ee9298d375cdec1447d0e46475fd68b51e0
5
+ SHA512:
6
+ metadata.gz: 459c55e39c0d28eb94d95d653b742bdcb92f502c37ab1e642be0fa4a3db29d4c0178bf3a6e9e3d50994b3a353853f672a1068e9d7cc7028f249be45fb34d1d26
7
+ data.tar.gz: d78e0207bd49bacb30cc01c0d74c0c8e4a8ee97f30bdbfa492cde1b34465a7536e76e67c7c700f9966ced6107f798830e32bb1520225b0ccf73bcc9624474a8f
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ ## Goals of this project
2
+
3
+ This project contains some add-on bindings to jruby Swing.
4
+
5
+ It is thus only really useful for jruby; and even there it
6
+ is very incomplete. Mega-beta quality, at best. I do not
7
+ recommend anyone to use this project as of yet.
8
+
9
+ ## Simplified quitting
10
+
11
+ Use the following method to quit easily:
12
+
13
+ do_quit
14
+
15
+ For instance, a quit button:
16
+
17
+ quit_button.on_clicked {
18
+ do_quit
19
+ }
data/doc/README.gen ADDED
@@ -0,0 +1,19 @@
1
+ ## Goals of this project
2
+
3
+ This project contains some add-on bindings to jruby Swing.
4
+
5
+ It is thus only really useful for jruby; and even there it
6
+ is very incomplete. Mega-beta quality, at best. I do not
7
+ recommend anyone to use this project as of yet.
8
+
9
+ ## Simplified quitting
10
+
11
+ Use the following method to quit easily:
12
+
13
+ do_quit
14
+
15
+ For instance, a quit button:
16
+
17
+ quit_button.on_clicked {
18
+ do_quit
19
+ }
@@ -0,0 +1,3 @@
1
+ require 'swing_paradise/requires/require_the_project.rb'
2
+
3
+ include SwingParadise
@@ -0,0 +1,54 @@
1
+ include Java
2
+
3
+ java_import javax.swing.JButton
4
+ java_import javax.swing.JFrame
5
+ java_import javax.swing.JLabel
6
+ java_import javax.swing.JPanel
7
+ java_import javax.swing.JTextArea
8
+ java_import javax.swing.JScrollBar
9
+ java_import javax.swing.JTextField
10
+ java_import javax.swing.JSpinner
11
+ java_import javax.swing.SpinnerNumberModel
12
+ java_import java.lang.System
13
+ java_import java.awt.Font
14
+
15
+ module SwingParadise
16
+
17
+ class QuitButtonExample < JFrame
18
+
19
+ require 'swing_paradise'
20
+ include SwingParadise
21
+
22
+ # ========================================================================= #
23
+ # === initialize
24
+ # ========================================================================= #
25
+ def initialize(
26
+ run_already = true
27
+ )
28
+ run if run_already
29
+ end
30
+
31
+ # ========================================================================= #
32
+ # === run
33
+ # ========================================================================= #
34
+ def run
35
+ frame = JFrame.new('A quit button example')
36
+ panel = JPanel.new # This is an instance of Java::JavaxSwing::JPanel.
37
+ panel.set_font(Font.new 'Sans serif', Font::PLAIN, 25)
38
+ frame.getContentPane.add(panel)
39
+ panel.setLayout(nil)
40
+ panel.hint = 'A quit button example'
41
+ _ = quit_button
42
+ _.setBounds(10, 20, 200, 40)
43
+ panel << _
44
+ frame.setDefaultCloseOperation JFrame::EXIT_ON_CLOSE
45
+ frame.setSize(600, 500)
46
+ frame.setLocationRelativeTo(nil)
47
+ frame.show_all
48
+ end
49
+
50
+ end; end
51
+
52
+ if __FILE__ == $PROGRAM_NAME
53
+ SwingParadise::QuitButtonExample.new
54
+ end
@@ -0,0 +1,46 @@
1
+ # =========================================================================== #
2
+ # require 'swing_paradise/jbutton/jbutton.rb'
3
+ # =========================================================================== #
4
+ class Java::JavaxSwing::JButton
5
+
6
+ # ========================================================================= #
7
+ # Enable: panel.hint=
8
+ # ========================================================================= #
9
+ alias hint= setToolTipText
10
+
11
+ alias on_clicked add_action_listener
12
+
13
+ # ========================================================================= #
14
+ # === on_event
15
+ # ========================================================================= #
16
+ alias on_event add_action_listener
17
+
18
+ # ========================================================================= #
19
+ # === use_this_font=
20
+ # ========================================================================= #
21
+ alias use_this_font= setFont
22
+
23
+ # ========================================================================= #
24
+ # === dimensions
25
+ #
26
+ # This is just a wrapper over setBounds() to allow us to work with
27
+ # a Hash instead.
28
+ # ========================================================================= #
29
+ def dimensions(
30
+ hash = {
31
+ x_axis: 10,
32
+ y_axis: 20,
33
+ width: 300,
34
+ height: 50
35
+ }
36
+ )
37
+ # is: x-coordinate, y-coordinate, width, height)
38
+ setBounds(
39
+ hash[:x_axis],
40
+ hash[:y_axis],
41
+ hash[:width],
42
+ hash[:height]
43
+ )
44
+ end
45
+
46
+ end
@@ -0,0 +1,28 @@
1
+ class Java::JavaxSwing::JComboBox
2
+
3
+ alias text? getSelectedItem # === text?
4
+
5
+ # ========================================================================= #
6
+ # === dimensions
7
+ #
8
+ # This is just a wrapper over setBounds() to allow us to work with
9
+ # a Hash instead.
10
+ # ========================================================================= #
11
+ def dimensions(
12
+ hash = {
13
+ x_axis: 10,
14
+ y_axis: 20,
15
+ width: 300,
16
+ height: 50
17
+ }
18
+ )
19
+ # is: x-coordinate, y-coordinate, width, height)
20
+ setBounds(
21
+ hash[:x_axis],
22
+ hash[:y_axis],
23
+ hash[:width],
24
+ hash[:height]
25
+ )
26
+ end
27
+
28
+ end
@@ -0,0 +1,61 @@
1
+ class Java::JavaxSwing::JFrame
2
+
3
+ java_import java.awt.Dimension
4
+
5
+ # ========================================================================= #
6
+ # === is_resizable
7
+ # ========================================================================= #
8
+ def is_resizable
9
+ JFrame.setResizable(true)
10
+ end
11
+
12
+ # ========================================================================= #
13
+ # === is_not_resizable
14
+ # ========================================================================= #
15
+ def is_not_resizable
16
+ JFrame.setResizable(false)
17
+ end
18
+
19
+ # ========================================================================= #
20
+ # === set_width
21
+ # ========================================================================= #
22
+ def set_width(i)
23
+ i = i.to_i
24
+ setPreferredSize(
25
+ java.awt.Dimension.new(i, -1)
26
+ )
27
+ end
28
+
29
+ # ========================================================================= #
30
+ # === show_all
31
+ # ========================================================================= #
32
+ def show_all
33
+ setVisible(true)
34
+ end
35
+
36
+ # ========================================================================= #
37
+ # === width_height
38
+ # ========================================================================= #
39
+ def width_height(
40
+ width = 1024,
41
+ height = 800
42
+ )
43
+ if width.is_a? String # This can be like this: '62% or minimum 300px'
44
+ if width.include? 'px'
45
+ scanned = width.scan(/(\d{1,}px)/)
46
+ width = scanned.flatten.first.delete('px')
47
+ end
48
+ end
49
+ if height.is_a? String # This can be like this: '62% or minimum 300px'
50
+ if height.include? 'px'
51
+ height = height.scan(/\d{1,}px/).flatten.first.delete('px')
52
+ end
53
+ end
54
+ width = width.to_i
55
+ height = height.to_i
56
+ setSize(width, height)
57
+ # The next variant does not appear to work that well:
58
+ # setPreferredSize(Dimension.new(width, height))
59
+ end
60
+
61
+ end
@@ -0,0 +1,31 @@
1
+ class Java::JavaxSwing::JLabel
2
+
3
+ # ========================================================================= #
4
+ # === use_this_font=
5
+ # ========================================================================= #
6
+ alias use_this_font= setFont
7
+
8
+ # ========================================================================= #
9
+ # === dimensions
10
+ #
11
+ # This is just a wrapper over setBounds() to allow us to work with
12
+ # a Hash instead.
13
+ # ========================================================================= #
14
+ def dimensions(
15
+ hash = {
16
+ x_axis: 10,
17
+ y_axis: 20,
18
+ width: 300,
19
+ height: 50
20
+ }
21
+ )
22
+ # is: x-coordinate, y-coordinate, width, height)
23
+ setBounds(
24
+ hash[:x_axis],
25
+ hash[:y_axis],
26
+ hash[:width],
27
+ hash[:height]
28
+ )
29
+ end
30
+
31
+ end
@@ -0,0 +1,37 @@
1
+ java_import java.awt.Font
2
+
3
+ class Java::JavaxSwing::JPanel
4
+
5
+ # ========================================================================= #
6
+ # Enable: panel.hint=
7
+ # ========================================================================= #
8
+ alias hint= setToolTipText
9
+
10
+ # ========================================================================= #
11
+ # Add << as alias to .add() next:
12
+ # ========================================================================= #
13
+ alias << add
14
+
15
+ # ========================================================================= #
16
+ # === font=
17
+ #
18
+ # This could be invoked like so:
19
+ #
20
+ # panel.font = :sans_serif_25
21
+ #
22
+ # It presently does not work, though.
23
+ # ========================================================================= #
24
+ # def font=(i)
25
+ # font_to_use = 'Sans serif'
26
+ # font_variant = Font::PLAIN # Font is actually Java::JavaAwt::Font
27
+ # font_size = 25
28
+ # if i.is_a? Symbol
29
+ # splitted = i.to_s.tr('_',' ').split(' ')
30
+ # font_size = splitted.pop
31
+ # font_to_use = splitted.join(' ')
32
+ # font_to_use[0, 1] = font_to_use[0, 1].upcase
33
+ # end
34
+ # set_font(Font.new(font_to_use), font_variant, font_size)
35
+ # end
36
+
37
+ end
@@ -0,0 +1,34 @@
1
+ # =========================================================================== #
2
+ # require 'swing_paradise/jscrollpane/jscrollpane.rb'
3
+ # =========================================================================== #
4
+ class Java::JavaxSwing::JScrollPane
5
+
6
+ # ========================================================================= #
7
+ # === use_this_font=
8
+ # ========================================================================= #
9
+ alias use_this_font= setFont
10
+
11
+ # ========================================================================= #
12
+ # === dimensions
13
+ #
14
+ # This is just a wrapper over setBounds() to allow us to work with
15
+ # a Hash instead.
16
+ # ========================================================================= #
17
+ def dimensions(
18
+ hash = {
19
+ x_axis: 10,
20
+ y_axis: 20,
21
+ width: 300,
22
+ height: 50
23
+ }
24
+ )
25
+ # is: x-coordinate, y-coordinate, width, height)
26
+ setBounds(
27
+ hash[:x_axis],
28
+ hash[:y_axis],
29
+ hash[:width],
30
+ hash[:height]
31
+ )
32
+ end
33
+
34
+ end
@@ -0,0 +1,10 @@
1
+ class Java::JavaxSwing::JSpinner
2
+
3
+ # ========================================================================= #
4
+ # === text?
5
+ # ========================================================================= #
6
+ def text?
7
+ getValue.to_s
8
+ end
9
+
10
+ end
@@ -0,0 +1,34 @@
1
+ # =========================================================================== #
2
+ # require 'swing_paradise/jtextarea/jtextarea.rb'
3
+ # =========================================================================== #
4
+ class Java::JavaxSwing::JTextArea
5
+
6
+ # ========================================================================= #
7
+ # === use_this_font=
8
+ # ========================================================================= #
9
+ alias use_this_font= setFont
10
+
11
+ # ========================================================================= #
12
+ # === dimensions
13
+ #
14
+ # This is just a wrapper over setBounds() to allow us to work with
15
+ # a Hash instead.
16
+ # ========================================================================= #
17
+ def dimensions(
18
+ hash = {
19
+ x_axis: 10,
20
+ y_axis: 20,
21
+ width: 300,
22
+ height: 50
23
+ }
24
+ )
25
+ # is: x-coordinate, y-coordinate, width, height)
26
+ setBounds(
27
+ hash[:x_axis],
28
+ hash[:y_axis],
29
+ hash[:width],
30
+ hash[:height]
31
+ )
32
+ end
33
+
34
+ end
@@ -0,0 +1,31 @@
1
+ class Java::JavaxSwing::JTextField
2
+
3
+ # ========================================================================= #
4
+ # === enable_dragging
5
+ # ========================================================================= #
6
+ def enable_dragging
7
+ setDragEnabled(true)
8
+ end
9
+
10
+ # ========================================================================= #
11
+ # === text?
12
+ # ========================================================================= #
13
+ def text?
14
+ getText.to_s
15
+ end
16
+
17
+ # ========================================================================= #
18
+ # === on_enter_pressed
19
+ # ========================================================================= #
20
+ def on_enter_pressed(&block)
21
+ add_action_listener(&block)
22
+ end
23
+
24
+ # ========================================================================= #
25
+ # === center
26
+ # ========================================================================= #
27
+ def center
28
+ setHorizontalAlignment(JTextField::CENTER)
29
+ end
30
+
31
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'swing_paradise/misc/misc.rb'
6
+ # =========================================================================== #
7
+ module SwingParadise
8
+
9
+ # ========================================================================= #
10
+ # === jframe
11
+ # ========================================================================= #
12
+ def jframe(i = '')
13
+ JFrame.new(i)
14
+ end; alias frame jframe # === frame
15
+
16
+ # ========================================================================= #
17
+ # === entry
18
+ #
19
+ # This is simply a wrapper over JTextField.
20
+ # ========================================================================= #
21
+ def entry(i = '')
22
+ JTextField.new(i)
23
+ end; alias hcentered_entry entry # === hcentered_entry
24
+ alias create_entry entry # === create_entry
25
+
26
+ # ========================================================================= #
27
+ # === quit_button
28
+ # ========================================================================= #
29
+ def quit_button(
30
+ use_this_text = 'Quit'
31
+ )
32
+ _ = button(use_this_text)
33
+ _.on_clicked { do_quit }
34
+ return _
35
+ end
36
+
37
+ end
@@ -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/jbutton/jbutton.rb'
6
+ require 'swing_paradise/jcombobox/jcombobox.rb'
7
+ require 'swing_paradise/jpanel/jpanel.rb'
8
+ require 'swing_paradise/jframe/jframe.rb'
9
+ require 'swing_paradise/jtextfield/jtextfield.rb'
10
+ require 'swing_paradise/jspinner/jspinner.rb'
11
+ require 'swing_paradise/jtextarea/jtextarea.rb'
12
+ require 'swing_paradise/jlabel/jlabel.rb'
13
+ require 'swing_paradise/jscrollpane/jscrollpane.rb'
14
+
15
+ require 'swing_paradise/misc/misc.rb'
@@ -0,0 +1,108 @@
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
+ # === swing_dimension
12
+ #
13
+ # This is a slight wrapper over java.awt.Dimension.
14
+ # ========================================================================= #
15
+ def swing_dimension(new_width, new_height)
16
+ java.awt.Dimension.new(new_width, new_height)
17
+ end
18
+
19
+ # ========================================================================= #
20
+ # === do_quit
21
+ #
22
+ # This method can be used as a more convenient do-exit method.
23
+ # ========================================================================= #
24
+ def do_quit(
25
+ use_this_as_the_exit_code = 0
26
+ )
27
+ System.exit(use_this_as_the_exit_code)
28
+ end
29
+
30
+ # ========================================================================= #
31
+ # === SwingParadise.text
32
+ #
33
+ # This method will return a JLabel instance.
34
+ # ========================================================================= #
35
+ def self.text(i = '')
36
+ _ = JLabel.new(i)
37
+ return _
38
+ end; self.instance_eval { alias label text } # === SwingParadise.label
39
+
40
+ # ========================================================================= #
41
+ # === jbutton
42
+ # ========================================================================= #
43
+ def jbutton(i = '')
44
+ return JButton.new(i)
45
+ end; alias button jbutton # === button
46
+
47
+ # ========================================================================= #
48
+ # === jcombobox
49
+ # ========================================================================= #
50
+ def jcombobox(i = nil)
51
+ combo_box = JComboBox.new
52
+ if i and i.respond_to?(:each)
53
+ i.each {|this_exam_topic|
54
+ combo_box.addItem(this_exam_topic)
55
+ }
56
+ end
57
+ return combo_box
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === default_close
62
+ # ========================================================================= #
63
+ def default_close
64
+ setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === jpanel
69
+ # ========================================================================= #
70
+ def jpanel
71
+ JPanel.new
72
+ end
73
+
74
+ # ========================================================================= #
75
+ # === jtextarea
76
+ # ========================================================================= #
77
+ def jtextarea
78
+ JTextArea.new
79
+ end
80
+
81
+ # ========================================================================= #
82
+ # === text
83
+ # ========================================================================= #
84
+ def text(i = '')
85
+ return JLabel.new(i)
86
+ end; alias jtext text # === jtext
87
+
88
+ # ========================================================================= #
89
+ # === show_message_dialog
90
+ # ========================================================================= #
91
+ def show_message_dialog(text = '')
92
+ javax.swing.JOptionPane.showMessageDialog(nil, text)
93
+ end
94
+
95
+ # ========================================================================= #
96
+ # === quit_button
97
+ #
98
+ # This method can be used to quickly create a quit-button.
99
+ # ========================================================================= #
100
+ def quit_button
101
+ _ = jbutton('Quit')
102
+ _.on_event {|event|
103
+ System.exit(0)
104
+ }
105
+ return _
106
+ end
107
+
108
+ 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.0.15'
11
+
12
+ # ========================================================================= #
13
+ # === LAST_UPDATE
14
+ # ========================================================================= #
15
+ LAST_UDPATE = '24.09.2022'
16
+
17
+ end
@@ -0,0 +1 @@
1
+ require 'swing_paradise/requires/require_the_project.rb'
@@ -0,0 +1,36 @@
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 for jruby only.
18
+
19
+ EOF
20
+
21
+ s.summary = DESCRIPTION
22
+ s.description = DESCRIPTION
23
+
24
+ s.authors = ['Robert A. Heiler']
25
+ s.email = Roebe.email?
26
+ s.files = Dir['**/*']
27
+
28
+ s.license = 'MIT'
29
+ s.homepage = 'https://www.rubydoc.info/gems/rbt/'
30
+ s.require_paths = ['lib']
31
+
32
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
33
+ s.required_rubygems_version = '>= '+Gem::VERSION
34
+ s.rubygems_version = '>= '+Gem::VERSION
35
+
36
+ }
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swing_paradise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.15
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2+
14
+
15
+ This gem is meant for jruby only.
16
+
17
+ email: shevy@inbox.lt
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - README.md
23
+ - doc/README.gen
24
+ - lib/swing_paradise.rb
25
+ - lib/swing_paradise/autoinclude.rb
26
+ - lib/swing_paradise/examples/001_quit_button_example.rb
27
+ - lib/swing_paradise/jbutton/jbutton.rb
28
+ - lib/swing_paradise/jcombobox/jcombobox.rb
29
+ - lib/swing_paradise/jframe/jframe.rb
30
+ - lib/swing_paradise/jlabel/jlabel.rb
31
+ - lib/swing_paradise/jpanel/jpanel.rb
32
+ - lib/swing_paradise/jscrollpane/jscrollpane.rb
33
+ - lib/swing_paradise/jspinner/jspinner.rb
34
+ - lib/swing_paradise/jtextarea/jtextarea.rb
35
+ - lib/swing_paradise/jtextfield/jtextfield.rb
36
+ - lib/swing_paradise/misc/misc.rb
37
+ - lib/swing_paradise/requires/require_the_project.rb
38
+ - lib/swing_paradise/toplevel_methods/misc.rb
39
+ - lib/swing_paradise/version/version.rb
40
+ - swing_paradise.gemspec
41
+ homepage: https://www.rubydoc.info/gems/rbt/
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.7.6
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 3.3.22
59
+ requirements: []
60
+ rubygems_version: 3.3.22
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: This gem is meant for jruby only.
64
+ test_files: []
65
+ ...