Cara Membuat Progressbar sederhana dengan Netbeans

on

Berikut step by step membuat progressbar sederhana:
1. buat project baru dengan nama berikut:

Hilangkan Centang pada Create Main Class

2. buat package baru:

dan akan muncul tampilan package-nya:

3. buat main class java:

dan akan muncul Tampilam Main classnya:

4. yang terakhir tinggal kita masukkan script berikut:

package prog;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import javax.swing.border.Border;
/**
*
* @author Excel.Os
*/
public class progressbar extends JFrame{
int a = 0;
JProgressBar progressBar = new JProgressBar(0, 100);
JLabel label = new JLabel();
Border border = BorderFactory.createTitledBorder("Waiting…");
public progressbar() {

progressBar.setStringPainted(true);
progressBar.setBorder(border);
label.setText("Program Dealler Counter");
label.setFont(new Font("Tahoma", 1, 24));
JPanel content = (JPanel)getContentPane();
content.setBackground(Color.blue);
Color warnaBorder =  Color.BLACK;
content.setBorder(BorderFactory.createLineBorder(warnaBorder, 5));
setLayout(null);
add(label);
label.setBounds(10, 10, 350, 100);
Component add = add(progressBar);
progressBar.setBounds(10, 130, 315, 40);
pack();
setSize(350, 250);
setVisible(true);
setLocationRelativeTo(null);
setDefaultCloseOperation(3);
while (a <= 100) {
progressBar.setValue(a);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
a += 1;
}
this.dispose();

this.setVisible(false);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new progressbar();
} catch (Exception ex) {
}

// TODO code application logic here
}
}

Semoga bermanfaat dan selamat mencoba..!
berikut outputnya:

Iklan

4 Comments Add yours

  1. get your ex back berkata:

    First of all I would like to say awesome blog!
    I had a quick question that I’d like to ask if you don’t mind.
    I was curious to find out how you center yourself and clear your mind before writing.

    I’ve had a difficult time clearing my thoughts in getting my thoughts out there. I do take pleasure in writing but it just seems like the first 10 to 15 minutes are lost just trying to figure out how to begin. Any ideas or hints? Cheers!

  2. Sugrahaku berkata:

    gan, di netbean sekarang kan ada pilihan di palette untuk progress bar, nah cara gunainnya gimana ya? terima kasih

  3. angga7 berkata:

    maaf, mau tanya sedikit, kalau untuk peletakkan coding tersbut di bagian yang mana ya? maklum masih newbie

  4. Good way of describing, and pleasant article to obtain facts concerning my presentation subject matter, which i
    am going to convey in college.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s