swing 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -0
- data/VERSION +1 -1
- data/lib/swing.rb +1 -0
- data/lib/swing/j_table.rb +2 -0
- data/lib/swing/j_text_field.rb +24 -0
- data/lib/swing_support/action_listener.rb +2 -2
- data/spec/swing/j_text_field_spec.rb +46 -0
- metadata +5 -2
data/HISTORY
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
data/lib/swing.rb
CHANGED
data/lib/swing/j_table.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'swing'
|
2
|
+
|
3
|
+
class Swing::JTextField
|
4
|
+
|
5
|
+
# action Action � � null
|
6
|
+
# columns int � � 0
|
7
|
+
# document Document � � PlainDocument( )
|
8
|
+
# horizontalAlignment int � � LEADING
|
9
|
+
# scrollOffset int � � From horizontal visibility
|
10
|
+
# ----Getters only - NO Setters!
|
11
|
+
# accessibleContext AccessibleContext � AccessibleJTextField
|
12
|
+
# actions Action[] � From superclass plus NotifyAction
|
13
|
+
# horizontalVisibility BoundedRangeModel � DefaultBoundedRangeModel
|
14
|
+
# UIClassIDo String � "TextFieldUI"
|
15
|
+
# ----Problematic or unimplemented!
|
16
|
+
# actionCommand String � null
|
17
|
+
#
|
18
|
+
attr_setter :action, :columns, :document, :horizontal_alignment, :scroll_offset
|
19
|
+
|
20
|
+
def add_block_listener &block
|
21
|
+
self.addActionListener SwingSupport::ActionListener.new &block
|
22
|
+
end
|
23
|
+
|
24
|
+
end # class JTextField
|
@@ -6,13 +6,13 @@ module SwingSupport
|
|
6
6
|
java_implements java.awt.event.ActionListener
|
7
7
|
|
8
8
|
def initialize &block
|
9
|
-
@
|
9
|
+
@listener_block = block
|
10
10
|
end
|
11
11
|
|
12
12
|
java_signature 'public void actionPerformed(ActionEvent event)'
|
13
13
|
# from ActionListener interface: Invoked when an action event occurs.
|
14
14
|
def actionPerformed event
|
15
|
-
@
|
15
|
+
@listener_block.call event
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'swing/shared'
|
3
|
+
|
4
|
+
class MyAction < Swing::AbstractAction
|
5
|
+
|
6
|
+
def actionPerformed ae
|
7
|
+
puts ae
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Swing::JTextField do
|
12
|
+
|
13
|
+
context 'creation' do
|
14
|
+
let(:new_args) { ['Text'] }
|
15
|
+
|
16
|
+
it_behaves_like 'enhanced Awt::Component'
|
17
|
+
it_behaves_like 'enhanced Swing::JComponent'
|
18
|
+
|
19
|
+
it 'is possible to set :action attribute' do
|
20
|
+
action = MyAction.new
|
21
|
+
tf = Swing::JTextField.new 'Actionable', :action => action
|
22
|
+
tf.get_action.should == action
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'is possible to set :action attribute' do
|
26
|
+
tf = Swing::JTextField.new 'Centered', :horizontal_alignment => Swing::JTextField::CENTER
|
27
|
+
tf.get_horizontal_alignment.should == Swing::JTextField::CENTER
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'is possible to set :action_command attribute' do
|
31
|
+
doc = Swing.text::PlainDocument.new
|
32
|
+
tf = Swing::JTextField.new 'Documented', :document => doc
|
33
|
+
# p (tf.methods-Object.methods).sort
|
34
|
+
tf.document.should == doc
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'accepts action listener block at initialization' do
|
38
|
+
button = Swing::JTextField.new('With block') { @block_called = true}
|
39
|
+
@block_called.should be_false
|
40
|
+
|
41
|
+
button.postActionEvent # emulate <ENTER>
|
42
|
+
@block_called.should be_true
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: swing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- arvicco
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-16 00:00:00 +04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/swing/j_scroll_pane.rb
|
69
69
|
- lib/swing/j_split_pane.rb
|
70
70
|
- lib/swing/j_table.rb
|
71
|
+
- lib/swing/j_text_field.rb
|
71
72
|
- lib/swing/old/button.rb
|
72
73
|
- lib/swing/old/check_box.rb
|
73
74
|
- lib/swing/old/frame.rb
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- spec/swing/j_scroll_pane_spec.rb
|
101
102
|
- spec/swing/j_split_pane_spec.rb
|
102
103
|
- spec/swing/j_table_spec.rb
|
104
|
+
- spec/swing/j_text_field_spec.rb
|
103
105
|
- spec/swing/shared.rb
|
104
106
|
- features/swing.feature
|
105
107
|
- features/step_definitions/swing_steps.rb
|
@@ -166,4 +168,5 @@ test_files:
|
|
166
168
|
- spec/swing/j_scroll_pane_spec.rb
|
167
169
|
- spec/swing/j_split_pane_spec.rb
|
168
170
|
- spec/swing/j_table_spec.rb
|
171
|
+
- spec/swing/j_text_field_spec.rb
|
169
172
|
- spec/swing/shared.rb
|