java问题:非法表达式的开始

importjava.applet.Applet;importjava.awt.*;importjava.util.Random;publicclassSnowPicex... import java.applet.Applet;
import java.awt.*;
import java.util.Random;
public class SnowPic extends Applet implements Runnable
{ Thread mainThread;
Image offScreen,gAlc[];
Random rand;
int stopFlag,snows,wind,threadSleep,snowSize;
int[] snowX,snowY;
long stopTime=0;
Dimension dim;
MediaTracker mt;
public SnowPic(){}
int getParameter(String s1,int s2)
{String s=getParameter(s1);
return(s!=null)? Integer.parseInt(s):s2;
}
int getParameter(String s1,int s2,int max,int min)
{
String s=getParameter(s1);
if (s!=null)
{
if((s2=Integer.parseInt(s))>max) return max;
else if (s2<min) return min;
else return s2;
}else return s2;
}
String getParameter(String s1,String s2)
{
String s=getParameter(s1);
return (S!=null)? s:s2;
}
public void init()
{
rand = new Random();
dim = getSize();
offScreen =createImage(dim.width,dim.height);
snows = getParameter("snows",100,500,0);
snowSize = getParameter("snowSize",3,10,3);
threadSleep = getParameter("threadsleep",80,100,10);
snowX=new int[snows];
snowY=new int[snows];
for(int i=0;i<snows;i++)
{
snowX[i]=rand.nextInt() % (dim.width /2)+dim.width/2;
snowY[i]=rand.nextInt() % (dim.height /2)+dim.height/2;
}
mt=new MediaTracker(this);
gAlc=new Image[1];
gAlc[0]=getImage(getDocumentBase(),getParameter("graphic","test.gif"));
mt.addImage(gAlc[0],0);

public void start()
{
if(mainThread != null)
{
mainThread=new Thread(this);
mainThread.start();
}
}
public void stop()
{
mainThread=null;
}
public void run()
{while (mainThread!=null)
{try
{Thread.sleep(threadSleep);
}
catch(InterruptedException_ex) {return;}
repaint();
}
}
public void drawBackSnow(Graphics g)
{g.setColor(Color.white);
for(int i=0;i<snows;i++)
{g.fillOval(snowX[i],snowY[i],snowSize,snowSize);
snowX[i]+=rand.nextInt()%2+wind;
snowY[i]+=(rand.nextInt()%6+5)/5+1;
if(snowX[i]>=dim.width) snowX[i]=0;
if(snowX[i]<0) snowX[i]=dim.width-1;
if(snowY[i]>=dim.height||snowY[i]<0);
{snowX[i]=Math.abs(rand.nextInt()%dim.width);
snowY[i]=0;
}
}
wind=rand.nextInt()%5-2;
}
public void paint(Graphics g)
{offScreen.getGraphics().setColor(Color.black;)
offScreen.getGraphics().fillRect(0,0,dim.width,dim.height);
offScreen.getGraphics().drawImage(gAlc[0],0,0,this);
drawBackSnow(offScreen.getGraphics());
g.drawImage(offScreen,0,0,null);
}
public void update(Graphics g)
{
paint(g);
}
;}
}

错误提示:
---------- 编译java程序 ----------
D:\java\SnowPic.java:53: 非法的表达式开始
public void start()
^
1 错误

输出完成 (耗时 0 秒)
展开
 我来答
郑贤德
推荐于2016-09-03 · 超过10用户采纳过TA的回答
知道答主
回答量:47
采纳率:0%
帮助的人:0
展开全部
import java.applet.Applet;
import java.awt.*;
import java.util.Random;

public class SnowPic extends Applet implements Runnable {
/**
*
*/
private static final long serialVersionUID = 1L;
Thread mainThread;
Image offScreen, gAlc[];
Random rand;
int stopFlag, snows, wind, threadSleep, snowSize;
int[] snowX, snowY;
long stopTime = 0;
Dimension dim;
MediaTracker mt;

public SnowPic() {
}

int getParameter(String s1, int s2) {
String s = getParameter(s1);
return (s != null) ? Integer.parseInt(s) : s2;
}

int getParameter(String s1, int s2, int max, int min) {
String s = getParameter(s1);
if (s != null) {
if ((s2 = Integer.parseInt(s)) > max)
return max;
else if (s2 < min)
return min;
else
return s2;
} else
return s2;
}

String getParameter(String s1, String s2) {
String s = getParameter(s1);
return (s != null) ? s : s2;
}

public void init(){
rand = new Random();
dim = getSize();
offScreen =createImage(dim.width,dim.height);
snows = getParameter("snows",100,500,0);
snowSize = getParameter("snowSize",3,10,3);
threadSleep = getParameter("threadsleep",80,100,10);
snowX=new int[snows];
snowY=new int[snows];
for(int i=0;i<snows;i++)
{
snowX[i]=rand.nextInt() % (dim.width /2)+dim.width/2;
snowY[i]=rand.nextInt() % (dim.height /2)+dim.height/2;
}
mt=new MediaTracker(this);
gAlc=new Image[1];
gAlc[0]=getImage(getDocumentBase(),getParameter("graphic","test.gif"));
mt.addImage(gAlc[0],0);
}
public void start()
{
if(mainThread != null)
{
mainThread=new Thread(this);
mainThread.start();
}
}
public void stop()
{
mainThread=null;
}
public void run()
{while (mainThread!=null)
{try
{Thread.sleep(threadSleep);
}
catch(Exception ex) {return;}
repaint();
}
}
public void drawBackSnow(Graphics g)
{g.setColor(Color.white);
for(int i=0;i<snows;i++)
{g.fillOval(snowX[i],snowY[i],snowSize,snowSize);
snowX[i]+=rand.nextInt()%2+wind;
snowY[i]+=(rand.nextInt()%6+5)/5+1;
if(snowX[i]>=dim.width) snowX[i]=0;
if(snowX[i]<0) snowX[i]=dim.width-1;
if(snowY[i]>=dim.height||snowY[i]<0);
{snowX[i]=Math.abs(rand.nextInt()%dim.width);
snowY[i]=0;
}
}
wind=rand.nextInt()%5-2;
}
public void paint(Graphics g)
{offScreen.getGraphics().setColor(Color.black);
offScreen.getGraphics().fillRect(0,0,dim.width,dim.height);
offScreen.getGraphics().drawImage(gAlc[0],0,0,this);
drawBackSnow(offScreen.getGraphics());
g.drawImage(offScreen,0,0,null);
}
public void update(Graphics g)
{
paint(g);
}

/*
* (non-Javadoc)
*
* @see java.lang.Runnable#run()
*/

}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式