回答編集履歴

1

コードを詳細化した。

2015/07/02 03:09

投稿

eripong
eripong

スコア1546

test CHANGED
@@ -12,13 +12,13 @@
12
12
 
13
13
  ```lang-java
14
14
 
15
- L00.setTitle("イメージを拡大コピー");
15
+ L00.setTitle("イメージを拡大コピー");
16
16
 
17
- L00.setDefaultCloseOperation(EXIT_ON_CLOSE);
17
+ L00.setDefaultCloseOperation(EXIT_ON_CLOSE);
18
18
 
19
- L00.setSize(300, 300);
19
+ L00.setSize(300, 300);
20
20
 
21
- L00.setVisible(true);
21
+ L00.setVisible(true);
22
22
 
23
23
  ```
24
24
 
@@ -26,28 +26,84 @@
26
26
 
27
27
  それから、ActionPerformedからThumbnailをnewするコードを追加してください。
28
28
 
29
- 追加箇所は、以下のドの次あたりと思います。
29
+ 以下のイメジです。
30
30
 
31
31
 
32
32
 
33
33
  ```lang-java
34
34
 
35
- String filepath = FilePathCreate();
35
+ String filepath = FilePathCreate();
36
36
 
37
- // 自分を消す(見えない位置に移動)
37
+ // 自分を消す(見えない位置に移動)
38
38
 
39
- mainFrame.setLocation(-1000,-1000);
39
+ mainFrame.setLocation(-1000,-1000);
40
40
 
41
- // 画面キャプチャ
41
+ // 画面キャプチャ
42
42
 
43
- screenShot.screenCapture(filepath);
43
+ screenShot.screenCapture(filepath);
44
44
 
45
45
 
46
46
 
47
- // 自分を表示(元の位置に移動)
47
+ // 自分を表示(元の位置に移動)
48
48
 
49
- mainFrame.setLocation(x, y);
49
+ mainFrame.setLocation(x, y);
50
50
 
51
51
 
52
52
 
53
+ // Thumbnailを表示
54
+
55
+ new Thumbnail(filepath);
56
+
53
57
  ```
58
+
59
+
60
+
61
+ Thumbnailのコンストラクタですが、以下のイメージと思います。
62
+
63
+
64
+
65
+ ```lang-java
66
+
67
+
68
+
69
+ public Thumbnail(String filePath) {
70
+
71
+ add(new DrawPanel(filePath));
72
+
73
+ setTitle("イメージを拡大コピー");
74
+
75
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
76
+
77
+ setSize(300, 300);
78
+
79
+ setVisible(true);
80
+
81
+ }
82
+
83
+ ```
84
+
85
+
86
+
87
+ それに伴い、DrawPanelのコンストラクタも以下の様に修正が必要です。
88
+
89
+
90
+
91
+ ```lang-java
92
+
93
+     public DrawPanel(String filePath) {
94
+
95
+        setBackground(Color.white); 
96
+
97
+
98
+
99
+         I00 = new ImageIcon(filePath).getImage(); 
100
+
101
+         I01 = I00.getWidth(this); 
102
+
103
+         I02 = I00.getHeight(this);
104
+
105
+     }
106
+
107
+ ```
108
+
109
+