以上的代码忘记了一对{}import java.applet.Applet;
import java.awt.*;public class DrawTemp extends Applet implements Runnable
{
Thread thisThread;
Graphics g; public void init()
{ } public void start()
{
thisThread=new Thread(this);
thisThread.start();
} public void stop()
{
thisThread.stop();
} public void run()
{
int xValue;
int yValue;
while (true)
{
xValue=(int)(getSize().width*Math.random());
yValue=(int)(getSize().height*Math.random());
g.drawLine(xValue,yValue,xValue,yValue);
try
{
thisThread.sleep(100);
}
catch (Exception e){}
}
}
}
import java.awt.*;public class DrawTemp extends Applet implements Runnable
{
Thread thisThread;
Graphics g; public void init()
{ } public void start()
{
thisThread=new Thread(this);
thisThread.start();
} public void stop()
{
thisThread.stop();
} public void run()
{
int xValue;
int yValue;
while (true)
{
xValue=(int)(getSize().width*Math.random());
yValue=(int)(getSize().height*Math.random());
g.drawLine(xValue,yValue,xValue,yValue);
try
{
thisThread.sleep(100);
}
catch (Exception e){}
}
}
}
import java.awt.*;public class DrawTemp extends Applet implements Runnable
{
Thread thisThread;
int xValue,yValue; public void init()
{
}
public void paint(Graphics g)
{
g.drawLine(xValue,yValue,xValue,yValue);
}
public void start()
{
thisThread=new Thread(this);
thisThread.start();
} public void stop()
{
thisThread.stop();
} public void run()
{
Dimension b =new Dimension();
b = getSize();
while (true)
{
xValue=(int)(b.width * Math.random());;
yValue=(int)(b.height * Math.random());
repaint();
try
{
thisThread.sleep(100);
}
catch (Exception e)
{}
}
}
}