通过线程实现动态欢迎页的效果
/*
*通过线程的方式,不断重画而实现动态欢迎页的效果

以下是代码部分:↓
*/
import java.awt.;
import javax.swing.;
public class Welcome extends JFrame{
Welcome(){
this.setSize(1440,900);
this.setUndecorated(true);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[]){
Welcome w=new Welcome();
MyWelcome mw=new MyWelcome();
mw.setBackground(Color.orange);
w.add(mw);
w.show();
}
}
class MyWelcome extends Panel implements Runnable{
String s[]={"欢","迎","使","用","世","荣","理","财","系","统"};
int l=0;
MyWelcome(){
Thread t=new Thread(this);
t.start();
}
public void paint(Graphics g){
Font f=new Font("",Font.BOLD,60);
g.setFont(f);
g.setColor(Color.green);
for(int i=0;i<l;i++){
g.drawString(s[i], 200+i*60, 300);
}
}
public void run() {
// TODO Auto-generated method stub
while(true){
l++;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
repaint();
if(l>=10){
l=0;
}
}
}
}
