Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Progress bar

package jframe; import java.awt.*; import javax.swing.*; public class progressdemo extends JFrame{ JProgressBar pb; int num=0; public progressdemo() { super("progress bar"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp=new JPanel(); UIManager.put("ProgressBar.background",Color.red); pb=new JProgressBar(0,20); pb.setValue(0); pb.setStringPainted(true); jp.add(pb); setContentPane(jp); pack(); setVisible(true); iterate(); } public void iterate() { while(num<=20) { pb.setValue(num); try { Thread.sleep(500); } catch(InterruptedException e) { } num=num+1; } } public static void main(String agrs[]) { new progressdemo();}}

You might also like