001/*
002 * Copyright (c) 1999-2001 Keiron Liddle, Aftex Software
003 *
004 * This library is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU Lesser General Public
006 * License as published by the Free Software Foundation; either
007 * version 2.1 of the License, or (at your option) any later version.
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012 * Lesser General Public License for more details.
013 *
014 */
015package com.aftexsw.util.bzip;
016
017import com.aftexsw.ui.*;
018
019import javax.swing.*;
020import java.awt.*;
021
022class BZipProgress extends JWindow implements ProgressListener {
023        JProgressBar pb = new JProgressBar();
024        long lastVal = -1;
025        long totalBytes = 200;
026
027        BZipProgress(long total, String name) {
028                totalBytes = total;
029                setSize(400, 40);
030                Util.centerFrame(this);
031                getContentPane().setLayout(new FlowLayout());
032                JLabel label = new JLabel("Progress of " + name + " :", JLabel.CENTER);
033                getContentPane().add(label);
034                getContentPane().add(pb);
035                setVisible(true);
036        }
037
038        public void setProgress(long val) {
039                if(val != lastVal) {
040                        pb.setValue((int)(100 * val / totalBytes));
041                        lastVal = val;
042                }
043        }
044}
045