コード public class AppletSize extends Applet{ Thread th; int Appletwidth; int Appletheight; Image img; public void init(){ Dimension size = getSize(); Appletwidth = size.width; Appletheight = size.width; System.out.println("Appletwidth :" + Appletwidth); System.out.println("Appletheight:" + Appletheight); img = createImage(size.width, size.width); Graphics buffer = img.getGraphics(); buffer.setColor(Color.black); buffer.fillRect(150, 150, 300, 500); } public void paint(Graphics g){ g.drawImage(img, 0, 0, this); } }
このようなプログラミングを作ったところAppletwidthとAppletheightの大きさは200でした。
initメソッドでbuffer.fillRect(0, 0, 300, 500);と書いているのに実行すると幅200高さ200の黒の四角形しかでませんでした。
これはAppletwidthとAppletheightの大きさが200だったからなのだと思うのですが、どうすればbuffer.fillRect(0, 0, 300, 500);を満たすようになるのでしょうか?
またAppletwidthとAppletheightの大きさは常に200なのでしょうか?
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。