I can't compile and run java applet.
簡単な、javaアプレットを作ったのですが、コンパイル、実行できません。
java
1import java.awt.Graphics; 2import java.awt.Color; 3 4/* 5<applet code="Main.class" width="150" height="150"> 6</applet> 7*/ 8 9public class Snows extends java.applet.Applet 10 implements Runnable { 11 12 Thread runner; 13 int xpos; 14 15 public void start() { 16 if (runner == null) { 17 runner = new Thread(this); 18 runner.start(); 19 } 20 } 21 22 public void stop() { 23 if (runner != null) { 24 runner.stop(); 25 runner = null; 26 } 27 } 28 29 public void run() { 30 setBackground(Color.blue); 31 while (true) { 32 for (xpos =5; xpos <= 105; xpos+=4) { 33 repaint(); 34 try { Thread.sleep(100); } 35 catch ( InterruptedException e) {} 36 } 37 for (xpos =105; xpos >5; xpos-=4) { 38 repaint(); 39 try { Thread.sleep(100); } 40 catch ( InterruptedException e) {} 41 } 42 } 43 } 44 45 public void paint(Graphics g) { 46 47 g.setColor(Color.black); 48 g.fillRect(0,0,100,100); 49 g.setColor(Color.white); 50 g.fillRect(101,0,100,100); 51 52 g.setColor(Color.red); 53 g.fillOval(xpos,5,90,90); 54 } 55}
回答2件
あなたの回答
tips
プレビュー