Java tutorial
import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.Timer; public class Main { public static void main(String[] args) { CountUpProgressBar cdpb = new CountUpProgressBar(); } } class CountUpProgressBar extends JPanel { JProgressBar bar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100); JLabel label = new JLabel("", JLabel.CENTER); Timer timer = new Timer(100, new ActionListener() { int counter = 1; @Override public void actionPerformed(ActionEvent ae) { label.setText(String.valueOf(counter)); bar.setValue(++counter); if (counter > 100) { timer.stop(); } } }); CountUpProgressBar() { super.setLayout(new GridLayout(0, 1)); bar.setValue(0); timer.start(); this.add(bar); this.add(label); JOptionPane.showMessageDialog(null, this); } }