谢谢了各位老大!
JAVA对我来说是个盲,谢谢你们帮个!!!
利用 Java 语言编写一个Applet程序,在程序中要使用多线程的创建方法,在屏幕中画一组同心圆,并且使网页展现出多姿多彩的动态效果。
注:java 中提供的画圆方法是: public abstract void DrawOval ( int x, int y, int width, int height )
要求: 1. 题材不限,除了表现出同心圆外,要包含文字、声音、图片(或者动画),要在网页中体现考生的信息(姓名、学号 等)。 2. 用 Word 文档写出设计的思路、模块功能划分、源程序代码、运行结果(文字说明配以屏幕截图),用 A4 纸打印,左侧装订。 3. 源程序的电子版(包括applet 源程序、对应的html文件和word文档的电子版)同时上交,放在以自己的学号及名字命名的文件夹中。
JAVA对我来说是个盲,谢谢你们帮个!!!
利用 Java 语言编写一个Applet程序,在程序中要使用多线程的创建方法,在屏幕中画一组同心圆,并且使网页展现出多姿多彩的动态效果。
注:java 中提供的画圆方法是: public abstract void DrawOval ( int x, int y, int width, int height )
要求: 1. 题材不限,除了表现出同心圆外,要包含文字、声音、图片(或者动画),要在网页中体现考生的信息(姓名、学号 等)。 2. 用 Word 文档写出设计的思路、模块功能划分、源程序代码、运行结果(文字说明配以屏幕截图),用 A4 纸打印,左侧装订。 3. 源程序的电子版(包括applet 源程序、对应的html文件和word文档的电子版)同时上交,放在以自己的学号及名字命名的文件夹中。
import java.awt.event.*;
import java.applet.*;public class test extends Applet
{
int[] OvalX,OvalY,X,Y;
myThread t1,t2;
Image image;
int ox;
Color[] c=new Color[50];
AudioClip audio;
public void init()
{
image=getImage(getDocumentBase(),"Images/1.gif");
for(int i=0;i<50;i++)
c[i]=new Color(i*5,i,i);
OvalX=new int[50];
OvalY=new int[50];
X =new int[50];
Y =new int[50];
try
{
audio=getAudioClip(getDocumentBase(),"1.au");
}
catch(Exception e){}
t1=new myThread(this);
t1.start();
audio.play();
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawString("测试",300,400);
g.drawImage(image,20,20,100,100,this);
for(int i=0;i<50;i++)
{
g.setColor(c[i]);
g.drawOval(X[i],Y[i],OvalX[i],OvalY[i]);
}
}
public void DrawOval(int x,int y,int w,int h)
{
int i;
if(ox==50)
{
for(i=0;i<50;i++)
{
X[i]=0;
Y[i]=0;
OvalX[i]=0;
OvalY[i]=0;
}
ox=0;
}
if(ox<50)
{
OvalX[ox] = w;
OvalY[ox] = h;
X[ox] = x;
Y[ox] = y;
ox++;
repaint();
}
}
}class myThread extends Thread
{
test applet;
boolean flag=true;
int x=200,y=200,width,height;
myThread(test a)
{
applet=a;
}
public void run()
{
while(true)
{
try
{
Thread.sleep(100);
}
catch(Exception e){}
if(width<400&&flag)
{
applet.DrawOval(x,y,width,height);
x=x-4;
y=y-4;
width=width+8;
height=height+8;
}
else
flag=false;
if(!flag&&width>0)
{
applet.DrawOval(x,y,width,height);
x=x+4;
y=y+4;
width=width-8;
height=height-8;
}
else
flag=true;
}
}
}
编个swing swt不更好