关闭

一个简单的进度条,applet实现

标签: appletimportstringclassnull
1476人阅读 评论(0) 收藏 举报
分类:
package com.border;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.*;


class Show extends JFrame{
        int num;
        JProgressBar current;

        public Show(int fileCount){
                super("Showtime by border...");
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                JFrame.setDefaultLookAndFeelDecorated(true);

                this.setResizable(false);
                this.setLocation(250,280);
                JPanel  p1=new JPanel();

                p1.setLayout(new FlowLayout(FlowLayout.CENTER));
                p1.setPreferredSize(new Dimension (550,40));
                JProgressBar progressBar = new JProgressBar (0,fileCount);
                progressBar.setPreferredSize(new Dimension (500,30));

                current = progressBar;
                current.setStringPainted(true);
                p1.add(current);

                setContentPane(p1);

        }
        public String iterate(int fileCount) {
                String fla = null;
                while(num<fileCount){
                                current.setValue(num);
                        try{
                                Thread.sleep(4000);
                         }catch(InterruptedException ee){}
                        num+=1;
                        System.out.println(num);
                        if(num>=fileCount){
                                fla="true";
                         }
                }
//              System.out.println(fla);
                return fla;
                }
}

public class ShowTime {
        public static void main(String[] age){
                int fileCount = 10;
                String tt;
                Show test=new Show(fileCount);
                test.pack();
                test.setVisible(true);
                tt=     test.iterate(fileCount);
                if(tt.equals("true")){
                        test.setVisible(false);
                 }
        }
}


下载代码:http://borderj.googlepages.com/ShowTime.rar
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:84960次
    • 积分:1287
    • 等级:
    • 排名:千里之外
    • 原创:42篇
    • 转载:7篇
    • 译文:0篇
    • 评论:19条
    文章分类
    最新评论