자바 진행 막대 작성

1103 단어
탭 JProgressbar 사용 하기:
package Chapter10;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.plaf.ProgressBarUI;

public class Demo17 extends JFrame{


	//JProgressBar   
	private static JProgressBar progress;
	public Demo1(){
		setTitle("      ");
		setBounds(100, 100, 300, 78);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		progress = new JProgressBar();
		//      
		progress.setStringPainted(true);
		getContentPane().add(progress,BorderLayout.CENTER);
		final JLabel jl = new JLabel("      ...");
		getContentPane().add(jl,BorderLayout.NORTH);
		setVisible(true);
	}
	public static void main(String[] args) {
		new Demo1();
		//           
		progress.setIndeterminate(true);
		for(int i=0;i<100;i++){
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			progress.setValue(i);
		}
		progress.setIndeterminate(false);
		progress.setString("    !");
	}

}

좋은 웹페이지 즐겨찾기