📄 yidongshape.java
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.color.*;
public class yidongshape implements Runnable
{
Thread t1;
int tim;
int with,heigh,j;
pp p1=new pp();
public yidongshape()
{
JFrame jf=new JFrame("yi dong shape");
j=0;
jf.setVisible(true);
jf.setSize(500,400);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.getContentPane().add(p1);
t1=new Thread(this);
t1.start();
}
public void setyidong(int tim)
{
this.tim=tim;
}
public void run()
{
for(int i=0;;i++)
{
try
{
if(with<=500)
{
with=with+10;
p1.setp(with,0);
}
else
{
with=501;
}
if(with==501&&heigh<=400)
{
heigh=heigh+10;
p1.setp(with,heigh);
}
else
{
heigh=401;
}
if(heigh>400)
{
//heigh=401;
with=with-10;
p1.setp(with,heigh);
}
/* else
{
with=500;
j++;
p1.setp(with-j*10,0);
}
if(heigh<400)
{
heigh=i*10;
p1.setp(0,heigh);
}*/
/* else
{
j++;
heigh=400;
p1.setp(0,heigh-j*10);
}*/
p1.repaint();
Thread.sleep(100);
}
catch(InterruptedException e)
{
}
}
}
public static void main (String[] args)
{
yidongshape a=new yidongshape();
}
}
class pp extends JApplet
{
int x,y;
public pp()
{
x=0;
y=0;
}
public void setp(int x,int y)
{
this.x=x;
this.y=y;
}
public void paint(Graphics g)
{
super.paint(g);
g.setColor(Color.green);
g.fill3DRect(x,y,20,20,true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -