package mhl.view;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Index extends JWindow {
Sping sp=null;
 public static void main(String args[])
 {
Index index=new Index();
 }
 Index()
 {  sp=new Sping();
   this.add(sp);
 this.setBounds(300,200,400,300);
 this.setVisible(true);
 }
}
class Sping extends JPanel implements Runnable{
int x=10;
int y=10;
int k=0;

public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
String str[]={"欢","迎","使","用","满","汗","楼","系","统","正","在","加","载","请","稍","后"};
   Sping()
   {
  this.setBounds(0, 0, 400, 300);
   Thread t=new Thread(this);
   t.start();
   }
   public void paint(Graphics g)
   {
    Font fot=new Font("宋体",Font.BOLD,20);
    g.setFont(fot);
   System.out.println("进入画图");
   System.out.println(this.getX()+"  "+this.getY());
   g.drawString(str[k],x,y);
 
      k++;
}
   public void run() {
   for(int i=0;i<4;i++)
     { this.setX(150-30*i);
      for(int j=0;j<4;j++)
      {this.setY(20+20*j);
      
     this.repaint();
      try {
     Thread.sleep(100);
     } catch (InterruptedException e) {
     e.printStackTrace();
     }
      }
     }
}

}

解决方案 »

  1.   


    public void run() {
    for (int i = 0; i < 4; i++) {
    this.setX(150 - 30 * i);
    for (int j = 0; j < 4; j++) {
    this.setY(20 + 20 * j);
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    repaint();
    }
    });

    try {
    Thread.sleep(100);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }
    }
      

  2.   


    Image im;

    Thread t=new Thread(this); 
    char ch[]={'欢','迎','光','临'};
    //String str=" ";
    int i=0;

     
    //构造函数
    public Paint()
    {
    t.start();
    try {
    im=ImageIO.read(new File("image//index.jpg"));
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

        //在这里做一个闪屏
    public void run() {
    // TODO Auto-generated method stub

    while(true)
    {
    try {

    Thread.sleep(3500);
    //str+=ch[i];
    if(i<=2)
    {
    i++;
    }

    } catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    }
    this.repaint();
    }
    }
    public void paintComponent(Graphics g) 
    {

    g.drawImage(im,0,0,400,240,this);
    g.drawString("正在进入系统,请稍等. . .", 150, 190);

    for(int j=0,x=70;j<=i;j++)
    {
    g.drawString(ch[j]+"", x, 120);
        x+=70;
    }

      

    }
    以前写的  输出结果是   欢   迎    光      临
      

  3.   

    但是String类学的不好,就简单了一点。楼主要耐性,会解决的!