swing 0.1.10 → 0.1.12
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.
- data/HISTORY +8 -0
- data/VERSION +1 -1
- data/lib/awt/component.rb +4 -2
- data/lib/swing/j_frame.rb +1 -2
- data/lib/swing/j_label.rb +21 -0
- data/spec/swing/j_label_spec.rb +24 -0
- data/spec/swing/j_table_spec.rb +0 -1
- data/spec/swing/shared.rb +15 -0
- metadata +1 -1
data/HISTORY
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.12
|
data/lib/awt/component.rb
CHANGED
@@ -26,6 +26,8 @@ class Awt::Component
|
|
26
26
|
# showing boolean � true
|
27
27
|
# valid boolean �
|
28
28
|
|
29
|
-
attr_setter :
|
30
|
-
:locale, :location, :name, :size, :visible
|
29
|
+
attr_setter :enabled, :layout,
|
30
|
+
:locale, :location, :name, :size, :visible,
|
31
|
+
:background => Awt::Color, :foreground => Awt::Color,
|
32
|
+
:font => Awt::Font, :cursor => Awt::Cursor
|
31
33
|
end
|
data/lib/swing/j_frame.rb
CHANGED
@@ -2,8 +2,7 @@ require 'swing'
|
|
2
2
|
|
3
3
|
class Swing::JFrame
|
4
4
|
|
5
|
-
attr_setter :
|
6
|
-
:default_close_operation => EXIT_ON_CLOSE #DISPOSE_ON_CLOSE, HIDE_ON_CLOSE
|
5
|
+
attr_setter :title, :default_close_operation => EXIT_ON_CLOSE #DISPOSE_ON_CLOSE, HIDE_ON_CLOSE
|
7
6
|
|
8
7
|
def initialize *args, &block
|
9
8
|
super *args, &nil
|
data/lib/swing/j_label.rb
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
require 'swing'
|
2
2
|
|
3
3
|
class Swing::JLabel
|
4
|
+
|
5
|
+
# Use either Swing::SwingConstants::XYZ or Swing::JLabel::XYZ for constants...
|
6
|
+
# UI LabelUI � � From L&F
|
7
|
+
# disabledIcon Icon � � null
|
8
|
+
# displayedMnemonic int/char � � KeyEvent.VK_UNDEFINED - both int and char setters
|
9
|
+
# displayedMnemonicIndex int -1 ?
|
10
|
+
# horizontalAlignment int � � LEADING - Also: TRAILING, LEFT, RIGHT, or CENTER
|
11
|
+
# horizontalTextPosition int � � TRAILING - Also LEFT, RIGHT, TOP, BOTTOM, CENTER
|
12
|
+
# icon Icon � � null
|
13
|
+
# iconTextGap int � � 4
|
14
|
+
# labelFor Component � � null
|
15
|
+
# text String � � null
|
16
|
+
# verticalAlignment int � � CENTER - Also TOP, BOTTOM, or CENTER
|
17
|
+
# verticalTextPosition int � � CENTER - Also LEFT, RIGHT, TOP, BOTTOM
|
18
|
+
# ----Getters only - NO Setters!
|
19
|
+
# accessibleContext AccessibleContext � JLabel.AccessibleJLabel
|
20
|
+
|
21
|
+
attr_setter :disabled_icon, :displayed_mnemonic, :displayed_mnemonic_index,
|
22
|
+
:horizontal_alignment, :horizontal_text_position, :icon, :icon_text_gap,
|
23
|
+
:label_for, :text, :vertical_alignment, :vertical_text_position
|
24
|
+
|
4
25
|
end # class JLabel
|
5
26
|
|
data/spec/swing/j_label_spec.rb
CHANGED
@@ -9,5 +9,29 @@ describe Swing::JLabel do
|
|
9
9
|
it_behaves_like 'enhanced Awt::Component'
|
10
10
|
it_behaves_like 'enhanced Swing::JComponent'
|
11
11
|
|
12
|
+
it 'allows to set properties via constructor' do
|
13
|
+
field = Swing::JTextField.new
|
14
|
+
icon = Swing::Icon.new
|
15
|
+
disabled_icon = Swing::Icon.new
|
16
|
+
properties = {
|
17
|
+
:disabled_icon => disabled_icon,
|
18
|
+
:displayed_mnemonic => 39,
|
19
|
+
:displayed_mnemonic_index => -1,
|
20
|
+
:horizontal_alignment => Swing::SwingConstants::RIGHT,
|
21
|
+
:horizontal_text_position => Swing::JLabel::RIGHT,
|
22
|
+
:icon => icon,
|
23
|
+
:icon_text_gap => 13,
|
24
|
+
:label_for => field,
|
25
|
+
:text => 'Bleh',
|
26
|
+
:vertical_alignment => Swing::SwingConstants::TOP,
|
27
|
+
:vertical_text_position => Swing::JLabel::TOP
|
28
|
+
}
|
29
|
+
@label = described_class.new *(new_args.push properties)
|
30
|
+
|
31
|
+
properties.each do |name, value|
|
32
|
+
@label.send(name).should == value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
12
36
|
end
|
13
37
|
end
|
data/spec/swing/j_table_spec.rb
CHANGED
data/spec/swing/shared.rb
CHANGED
@@ -32,6 +32,21 @@ shared_examples_for 'enhanced Awt::Component' do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
it 'even auto-creates proper classes for given properties' do
|
36
|
+
properties = {
|
37
|
+
:background => [1, 2, 3],
|
38
|
+
:foreground => [3, 2, 1],
|
39
|
+
:font => ["Trebuchet", Awt::Font::PLAIN, 11],
|
40
|
+
:locale => locale,
|
41
|
+
:location => [100, 200],
|
42
|
+
:size => [300, 300],
|
43
|
+
}
|
44
|
+
@component = described_class.new *(args.push properties)
|
45
|
+
@component.background.should == Awt::Color.new(1, 2, 3)
|
46
|
+
@component.foreground.should == Awt::Color.new(3, 2, 1)
|
47
|
+
@component.font.should == Awt::Font.new("Trebuchet", Awt::Font::PLAIN, 11)
|
48
|
+
end
|
49
|
+
|
35
50
|
context 'new with parent' do
|
36
51
|
unless described_class == Swing::JFrame || described_class == Swing::JMenuBar
|
37
52
|
it 'sets parent via options' do
|