JAVA有几种方式来显示进度条
请最好举例说明一下啊 
谢谢了  

解决方案 »

  1.   

    jmf的问题   我也想了好长时间了。更惨!   连音乐都不能播放,网上又找不到这方面的文章! 
    我把我的代码给你发一下   可以帮我看下吗??谢谢了!!! 
    import   javax.media.*; 
    import   javax.swing.JFrame; 
    import   javax.swing.JFileChooser; 
    import   javax.swing.JMenuItem; 
    import   javax.swing.JMenu; 
    import   java.awt.event.*; 
    import   javawork.swing.*; 
    import   java.awt.Container; 
    import   javax.swing.JPanel; 
    import   javax.swing.JMenuBar; 
    import   java.io.IOException; public   class   VideoPlayer   extends   JFrame 
    { public   VideoPlayer() 
    {     fileToBeAdded.addActionListener(new   fileListener()); 
        files.add(fileToBeAdded); 
        
        super.setTitle(fileURL); 
        System.out.println(fileURL); 
        bar.add(files); 
        JPanel   p   =   new   JPanel(); 
        p.add(bar); 
          Container   cp   =   getContentPane(); 
          cp.add(p); 
              System.out.println(fileURL);     } 
        
        
        
        
        private   JMenuItem   fileToBeAdded   =   new   JMenuItem( "open "); 
    private   JMenu   files   =   new   JMenu( "file "); 
    private   JMenuBar   bar   =   new   JMenuBar(); 
    private   String     fileURL=null; 
    private   Player   player   =   null; 
    private   MediaLocator   sourceLocator   =   null; 
    class   fileListener   implements   ActionListener 
    { public   void   actionPerformed(ActionEvent   e) 
    { JFileChooser   jFileChooser   =   new   JFileChooser(); 
    int   val=jFileChooser.showOpenDialog(VideoPlayer.this); 
    if(val==JFileChooser.APPROVE_OPTION) 

    String   fileDir   =   jFileChooser.getCurrentDirectory().toString(); 
        String   fileName   =   jFileChooser.getSelectedFile().getName(); 
    fileURL   = "file:/// "+fileDir+ "\\ "+fileName; 
    // fileURL   = " "+fileDir+ "\\ "+fileName; 
    System.out.println(fileURL); 

    sourceLocator   =   new   MediaLocator(fileURL); 
    try 

          player   =     Manager.createPlayer(sourceLocator); 
    // player.addControllerListener(new   controlListener()); 
                }catch(IOException   iOe) 
                { 
                iOe.printStackTrace(); 
                } 
                catch(NoPlayerException   pe) 
                { 
                } 
    player.start();   

    } public   static   void   main(String   []   args) 

    Console.run(new   VideoPlayer(),80,40); 


    这是上面那个程序要引入的   import   javawork.swing.*; 
    package   javawork.swing; 
    import   javax.swing.*; 
    import   java.awt.event.*; 
    import   java.awt.*; public   class   Console   { 
        //   Create   a   title   string   from   the   class   name: 
        public   static   String   title(Object   o)   { 
            String   t   =   o.getClass().toString(); 
            //   Remove   the   word   "class ": 
            if(t.indexOf( "class ")   !=   -1) 
                t   =   t.substring(6); 
            return   t; 
        } 
        public   static   void   
        run(JFrame   frame,   int   width,   int   height)   { 
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            frame.setSize(width,   height); 
            frame.setVisible(true); 
        } 
        public   static   void   
        run(JApplet   applet,   int   width,   int   height)   { 
            JFrame   frame   =   new   JFrame(title(applet)); 
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            frame.getContentPane().add(applet); 
            frame.setSize(width,   height); 
            applet.init(); 
            applet.start(); 
            frame.setVisible(true); 
        } 
        public   static   void   
        run(JPanel   panel,   int   width,   int   height)   { 
            JFrame   frame   =   new   JFrame(title(panel)); 
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            frame.getContentPane().add(panel); 
            frame.setSize(width,   height); 
            frame.setVisible(true); 
        } 
    }   ///:~ 
      

  2.   

    可以用SWING来做 但是 我上次 听别人说的有些更多的方法  所以咨询一下啊
      

  3.   

     用线程 还知道点..
    用JScrollPane 怎么做啊 
      

  4.   

    /**
     * @(#)ProgressTest.java
     *
     *
     * @author 张栋芳QQ271536394
     * @version 1.00 2008/3/13
     */import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.JProgressBar;
    public class ProgressTest extends JDialog{
    public JProgressBar jpb;
    public  int Max=100;
    public  int Min=0;
    public  int Count=1;
    public JButton bStart;
        public ProgressTest() {
           
        
         Container con=(JPanel)this.getContentPane();
         con.setLayout(null);
         bStart=new JButton("开始");
         bStart.setBounds(10,10,70,30);
         bStart.addActionListener(new MyActionListener());
        
         jpb=new JProgressBar();
         jpb.setBounds(80,20,300,20);
         jpb.setMaximum(Max);
         jpb.setMinimum(Min);
         jpb.setAutoscrolls(true);
         jpb.setStringPainted(true);//进度字
         //jpb.setValue(50);
         con.add(bStart);
         con.add(jpb);
         this.setSize(400,300);
         this.setTitle("进度条的小程序");
         this.setLocationRelativeTo(this);
         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         this.setVisible(true);
        
        }
        public static void main(String[] args){
         ProgressTest test=new ProgressTest();
        }
        private class MyActionListener implements ActionListener{
         public void actionPerformed(ActionEvent e){
         if(e.getSource().equals(bStart)){
         System.out.println ("ok");
             UpThread thread=new UpThread();
         thread.start();
         }
         }
        }
        
    class UpThread extends Thread{
    public UpThread(){ }
        public void run(){
         Count=Min;
         while(Count<=Max){
         Count++;
             jpb.setValue(Count);
         try{
         if(Count<40){
         this.sleep(50);
         }
         if(Count>=40&&Count<70){
         this.sleep(200);
         }
         if(Count>=70){
         this.sleep(50);
         }
        
         }catch(Exception ae){
         ae.printStackTrace();
         }
         }
        
        
        }
    }}