質問編集履歴
5
eclipseでの実行
test
CHANGED
File without changes
|
test
CHANGED
@@ -121,3 +121,9 @@
|
|
121
121
|
```
|
122
122
|
|
123
123
|
![イメージ説明](f9438aee8ba6b637b1f501a296a0173d.png)
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
![イメージ説明](f33597609f7efc3a06f7fd687eb59e1b.png)
|
4
sampleコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -77,3 +77,47 @@
|
|
77
77
|
```
|
78
78
|
|
79
79
|
![イメージ説明](6a53964effe8bf6dd5d71bdb30b8de6d.png)
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
簡単なsampleコードを作ってみましたがうまく動きません。
|
88
|
+
|
89
|
+
```java
|
90
|
+
|
91
|
+
public class AppletMain extends Applet {
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
protected Image player;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
// 一番最初にのみ実行される。
|
100
|
+
|
101
|
+
public void init() {
|
102
|
+
|
103
|
+
player = getImage(getCodeBase(), "im.jpg");
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
// 表示させるメソッド
|
110
|
+
|
111
|
+
public void paint(Graphics g) {
|
112
|
+
|
113
|
+
g.drawLine(0, 0, 200, 200);
|
114
|
+
|
115
|
+
g.drawImage(player, 500, 500, 150, 200, this);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
![イメージ説明](f9438aee8ba6b637b1f501a296a0173d.png)
|
3
webのURLでは動いたことの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
画像も実行ファイルと同じ場所にインポートしました。
|
6
6
|
|
7
7
|
なぜうまく描画されないのかご教授お願い致します。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
*web上の下記のようなURLの場合は問題なく動作します。
|
12
|
+
|
13
|
+
https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSWS0cOORLbx3eZfRCNVNbSTF_fqkaZLZo_LOp522PQVYclrLtieA
|
8
14
|
|
9
15
|
|
10
16
|
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,15 +46,23 @@
|
|
46
46
|
|
47
47
|
back = createImage(size.width, size.height);
|
48
48
|
|
49
|
-
|
49
|
+
buffer = back.getGraphics();
|
50
50
|
|
51
51
|
}
|
52
52
|
|
53
53
|
public void paint(Graphics g){
|
54
54
|
|
55
|
-
|
55
|
+
OutputScreen(buffer);
|
56
56
|
|
57
|
-
g.drawImage(back, 0, 0, this);
|
57
|
+
g.drawImage(back, 0, 0, this);
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
public void OutputScreen(Graphics g){
|
64
|
+
|
65
|
+
g.drawImage(player,500,500, 150,200,this);
|
58
66
|
|
59
67
|
}
|
60
68
|
|
1
コードが抜けていたため追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,6 +30,10 @@
|
|
30
30
|
|
31
31
|
protected Image player;
|
32
32
|
|
33
|
+
protected Image back;
|
34
|
+
|
35
|
+
protected Graphics buffer;
|
36
|
+
|
33
37
|
|
34
38
|
|
35
39
|
public void init(){
|
@@ -38,6 +42,20 @@
|
|
38
42
|
|
39
43
|
player = getImage(getCodeBase(), deck.getPlayerChar());
|
40
44
|
|
45
|
+
Dimension size = getSize();
|
46
|
+
|
47
|
+
back = createImage(size.width, size.height);
|
48
|
+
|
49
|
+
buffer = back.getGraphics();
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
public void paint(Graphics g){
|
54
|
+
|
55
|
+
g.drawImage(player,500,500, 150,200,this);
|
56
|
+
|
57
|
+
g.drawImage(back, 0, 0, this);
|
58
|
+
|
41
59
|
}
|
42
60
|
|
43
61
|
}
|