java swing jprpgressbar

我希望能做一个类似MyEclipse启动时的动画效果,代码中的图片劳烦随便用一个400*300的图片代替,主要是希望jProgressBar能在底部,而且要和jWindow  的宽一样,不是默认的这么短,能改变progressbar的宽?还是只能用绘图的方法代替?
 
引包就免了
public class Index extends JWindow implements Runnable{
 //主涵
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Index index = new Index();
  Thread thread = new Thread(index);
  thread.start();
 }
 Paint paint = null;
 //构造
 public Index(){
  paint = new Paint();
  this.add(paint);
  this.setSize(400, 300);
  this.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width/2)-200,
    (Toolkit.getDefaultToolkit().getScreenSize().height/2)-150);
  this.setVisible(true);
 }
 @Override
 public void run() {
  // TODO Auto-generated method stub
 }
}
//绘图
class Paint extends JPanel implements Runnable{
 Thread thread;
 int i=0;
 JProgressBar jProgressBar = null;
 public Paint(){
  jProgressBar = new JProgressBar(0,1500);
  jProgressBar.setValue(0);
  jProgressBar.setStringPainted(true);
  thread=new Thread(this);
  thread.start();
 }
 public void paintComponent(Graphics g){
  Image image = Toolkit.getDefaultToolkit().getImage("images\\welcome.jpg");
  g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
 }
 @Override
 public void run() {
  // TODO Auto-generated method stub
  while(i<=1500){
   jProgressBar.setValue(i++);
   try {
    Thread.sleep(5);
   } catch (Exception e) {
    e.printStackTrace();
   }
  }
 }
}

你可能感兴趣的:(java,ProgressBar)