hallo kawan2, udah lama ni saya g posting2, maaf karena saya kebanyakan tugas kuliah, UTS dan UAS..
kali ini saya pngen share sedikit tentang pemrograman java memakai netbeans, kawan-kawan pasti tau donk?? hayo masa anak teknik informatika g tau sih?,
kalo kawan2 tau UNINDRA disana java hanya menggunakan Blue J saja, dari Java Pengenalan sampe sekarang..
kayanya seperti nasi tanpa lauk,, hha jadi laper nii, maklum saya posting ini dengan keadaan belum sarapan pagi.. :)
saya coba jelaskan sedikit apa itu netbeans,
Netbeans adalah software programming java yang kaya fitur j2ee, j2Me, mobilitypack dll, dan biasa digunakan untuk membuat pemrograman java yang berbasis GUI, untuk games, applikasi dll,
sayangnya dikampus saya java programmingnya tidak menggunakan Netbeans.. hiksd2.. T.T
ini penampakannya :
Udah siap belum untuk memulai program java pertama dengan netbeans?
jika kawan belum punya silahkan download softwarenya disini
jangan lupa pastikan JDKnya telah terinstall dikomputer/laptop, klo belum punya silahkan download disini
kalau sudah, buka netbeansnya lalu klik file-newproject choose project-Java Application lalu buat project yg ingin kita buat, misalkan kita beri nama projectnya Coba kemudian hilangkan pilihan Create Main Class, karena kita langsung membuat main class pada form program sederhana yg akan kita buat.
Klik kanan pada Project yang baru dibuat, pilih New | JFrame Form…
Beri nama Form yang baru dibuat dengan nama hadiah, sebagai contoh tutor . Klik finish. Kita akan diberi satu buah form yang bisa didesain secara leluasa.
codingannya :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* hadiah.java
*
* Created on Dec 4, 2011, 10:53:25 AM
*/
/**
*
* @author Eka.ilaika
*/
public class hadiah extends javax.swing.JFrame {
/** Creates new form hadiah */
public hadiah() {
initComponents();
}
private String str = " ";
private int Tot;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
tfTot = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
tfHadiah = new javax.swing.JTextField();
bCek = new javax.swing.JButton();
bCa = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("GEBYAR HADIAH PT ALFAMART");
jLabel1.setBackground(new java.awt.Color(204, 0, 204));
jLabel1.setFont(new java.awt.Font("MS UI Gothic", 3, 18)); // NOI18N
jLabel1.setForeground(new java.awt.Color(51, 51, 255));
jLabel1.setText("\"GEBYAR HADIAH PT ALFAMART\"");
jTextArea1.setBackground(java.awt.Color.green);
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setRows(5);
jTextArea1.setText("\"Dalam rangka Merayakan Ultah Alfamart ke 7 tahun, Alfamart menyelenggarakan\n Gebyar Hadiah dengan Alokasi total belanja dari 50rb sampai 100rb. Dapatkan\n Hadiah Langsung dari kami\".\n\n\t\"TERIMA KASIH ATAS KESETIAAN PARA PELANGGAN\"\n\t\t:::::::::::::::::::::::::::::::::::::");
jTextArea1.setCaretColor(new java.awt.Color(153, 0, 153));
jTextArea1.setSelectedTextColor(new java.awt.Color(204, 0, 204));
jTextArea1.setSelectionColor(new java.awt.Color(255, 0, 255));
jScrollPane1.setViewportView(jTextArea1);
jLabel2.setText("Masukkan Total Belanja :");
tfTot.setText("0");
jLabel3.setText("Rp.");
jLabel4.setText("Hadiah Anda Adalah :");
tfHadiah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tfHadiahActionPerformed(evt);
}
});
bCek.setText("Cekidot!!");
bCek.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bCekActionPerformed(evt);
}
});
bCa.setText("Clear All");
bCa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bCaActionPerformed(evt);
}
});
jLabel5.setText("::This Program Created By EkaIlaika 5H Teknik INFORMATIKA UNINDRA PGRI::");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
.addGap(40, 40, 40))
.addGroup(layout.createSequentialGroup()
.addGap(69, 69, 69)
.addComponent(jLabel1)
.addContainerGap(108, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(bCa, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(jLabel3))
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(tfTot, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bCek, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addComponent(tfHadiah, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))))
.addGap(113, 113, 113))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(tfTot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(bCek))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(tfHadiah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bCa)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
.addComponent(jLabel5))
);
pack();
}//
private void tfHadiahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void bCekActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Tot = Integer.parseInt(tfTot.getText());
if (Tot>=100000)
tfHadiah.setText("Payung AlfaMart");
else if (Tot>=84000)
tfHadiah.setText("Jam Dinding AlfaMart");
else if (Tot>=74000)
tfHadiah.setText("Gantungan Kunci AlfaMart");
else if (Tot>=50000)
tfHadiah.setText("Sapu tangan AlfaMart");
else
tfHadiah.setText("Belanja Anda Belum Mencukupi");
}
private void bCaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (bCa.isSelected()==true){
tfHadiah.setEditable(false);
}
else{
tfHadiah.setEditable(true);
tfHadiah.setText("");
tfTot.setText("0");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new hadiah().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton bCa;
private javax.swing.JButton bCek;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField tfHadiah;
private javax.swing.JTextField tfTot;
// End of variables declaration
}
Simpan project
Klik kanan pada form yang baru dibuat dan klik Run atau tekan tombol SHIFT + F6, maka program akan berjalan..
jika ingin mengubah desain bisa menggunakan pallete tools yang ada dinetbeans,, ayo berkreasi..
ini penampakannya :
Selamat, kita sudah membuat 1 buah program aplikasi yang akan menjadi langkah awal kecintaan anda pada Java .
Semoga Bermanfaat... kalo ada pertanyaan silahkan komment aja yahh..
0 comments:
Post a Comment