7
Loaad Form Dengan ProgresBar Untuk menampilkan form dengan progrebar ada beberapa langkah diantaranya : 1. Bua tlah s ebu ah pojek deng an nama Loa dFo rm. Buatlah class dan form dengan nama seperti di tunjukan gambar dibawah:

JProgresBar

Embed Size (px)

Citation preview

Page 1: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 1/7

Loaad Form Dengan ProgresBar 

Untuk menampilkan form dengan progrebar ada beberapa langkah diantaranya :

1. Buatlah sebuah pojek dengan nama LoadForm.

Buatlah class dan form dengan nama seperti di tunjukan gambar dibawah:

Page 2: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 2/7

desain tamilan pada form.

Dan kodenya adalah sbb:

** DILARANG MERUBAH ATAU MENGHAPUS HAK CIPTA INI

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

* Hak cipta ASEP KOMARUDIN

* Semua isi dalam file ini adalah hak milik dari asep komarudin

* anda tidak diperkenankan untuk mengunakan file atau mengubah file ini

* kecuali anda tidak merubah atau menghapus hak cipta ini

*

* Pemilik tidak bertanggung jawab jika anda menyalah gunakan file ini

* pemilik tidak menjamin apapun atas file ini

** Anda bisa menghubungi pemilik hak cipta ini

* email :[email protected]

* tlp :081383551124

* blog :http://aasseepp.blogspot.com/

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

*/

/*

* Progres.java

*

* Created on 18 Jul 11, 21:54:41*/

 package asep.progresbar.progres;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Toolkit;

import javax.swing.ImageIcon;

import javax.swing.JComponent;

import javax.swing.JDialog;

import javax.swing.JProgressBar;import javax.swing.plaf.PanelUI;

Page 3: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 3/7

/**

*

* @author asep

*/

 public class Progres extends javax.swing.JDialog {

/** Creates new form Progres */public Progres() {

setUndecorated(true);

initComponents();

Splashpanel.setUI(new BegrundUi());

Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();

int x=(dim.width-getWidth())/2;

int y=(dim.height-getHeight())/2;

setLocation(x, y);

ProgressBar.setStringPainted(true);

}

public JProgressBar getProgressBar() {

return ProgressBar;

}

 

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

 private void initComponents() {

Splashpanel = new javax.swing.JPanel();

ProgressBar = new javax.swing.JProgressBar();

@SupersWarnings(“unchecked”)

/**

* @param args the command line arguments

*/

 

// Variables declaration - do not modify

 private javax.swing.JProgressBar ProgressBar;

private javax.swing.JPanel Splashpanel;

// End of variables declaration

}

class BegrundUi extends PanelUI{

ImageIcon begron=new ImageIcon(getClass().getResource(""

+ "/asep/progresbar/icon/Komputer.png"));

@Overridepublic void paint(Graphics g, JComponent c) {

g.drawImage(begron.getImage(), 0, 0, null);

Page 4: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 4/7

}

 

}

Desain tampilan untuk form utama.

Kodenya adalah:

/*

* DILARANG MERUBAH ATAU MENGHAPUS HAK CIPTA INI* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

* Hak cipta ASEP KOMARUDIN

* Semua isi dalam file ini adalah hak milik dari asep komarudin

* anda tidak diperkenankan untuk mengunakan file atau mengubah file ini

* kecuali anda tidak merubah atau menghapus hak cipta ini

*

* Pemilik tidak bertanggung jawab jika anda menyalah gunakan file ini

* pemilik tidak menjamin apapun atas file ini

*

* Anda bisa menghubungi pemilik hak cipta ini

* email :[email protected]* tlp :081383551124

* blog :http://aasseepp.blogspot.com/

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

*/

/*

* Form.java

*

* Created on 18 Jul 11, 22:24:06

*/

 package asep.progresbar.progres;

Page 5: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 5/7

import java.awt.Color;

/**

*

* @author asep

*/ public class Form extends javax.swing.JFrame {

/** Creates new form Form */

public Form() {

initComponents();

setLocationRelativeTo(null);

jPanel1.setBackground(Color.green);

}

/**

* @param args the command line arguments

*/public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Form().setVisible(true);

}

});

}

@SupersWarnings(“unchecked”)

// Variables declaration - do not modify private javax.swing.JLabel jLabel1;

private javax.swing.JPanel jPanel1;

// End of variables declaration

}

Kode pada kelas jalankan:

/*

* DILARANG MERUBAH ATAU MENGHAPUS HAK CIPTA INI

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

* Hak cipta ASEP KOMARUDIN* Semua isi dalam file ini adalah hak milik dari asep komarudin

* anda tidak diperkenankan untuk mengunakan file atau mengubah file ini

* kecuali anda tidak merubah atau menghapus hak cipta ini

*

* Pemilik tidak bertanggung jawab jika anda menyalah gunakan file ini

* pemilik tidak menjamin apapun atas file ini

*

* Anda bisa menghubungi pemilik hak cipta ini

* email :[email protected]

* tlp :081383551124

* blog :http://aasseepp.blogspot.com/

* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Page 6: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 6/7

*/

 package asep.progresbar.progres;

import java.util.logging.Level;

import java.util.logging.Logger;

/**

*

* @author asep

*/

 public class Jalankan {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic hereProgres p=new Progres();

p.setVisible(true);

for(int i=0;i<100;i++){

try {

p.getProgressBar().setValue(i);

Thread.sleep(50);

} catch (InterruptedException ex) {

Logger.getLogger(Jalankan.class.getName()).log(Level.SEVERE, null, ex);

}

}p.dispose();

Form f=new Form();

f.setVisible(true);

}

}

Dan jika dijalankan keluarannya adalah:

dan ketika 100% maka akn muncul:

Page 7: JProgresBar

8/6/2019 JProgresBar

http://slidepdf.com/reader/full/jprogresbar 7/7