- Langkah awal kalian harus megklik Text Field, Text Area, Combo Box, dan Button satu per-satu tidak boleh berbarengan.
- Setelah itu klik kanan pada Text Field, Text Area, Combo Box, dan Button.
- Setelah itu klik Change Variable Name...
- Lalu ubah menjadi
TextArea1 : no
TextArea2 : nama
TextArea3 : alamat
Combo Box : jeniskelamin/ jenis_kelamin (tidak boleh menggunakan spasi, jdi pengganti spasi adalah garis bawah seperti contoh disamping).
TextArea4 : tangal_lahir
Button1 : bersih
Button2 : proses
Button3 : keluar
setelah itu baru masuk kodingan
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package biodata_siswa;
- /**
- *
- * @author Rei Fandi
- */
- public class projectbiodata extends javax.swing.JFrame {
- /**
- * Creates new form projectbiodata
- */
- public projectbiodata() {
- initComponents();
- }
- /**
- * 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")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jButton3 = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- no = new javax.swing.JTextField();
- nama = new javax.swing.JTextField();
- alamat = new javax.swing.JTextField();
- jLabel5 = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- biodata = new javax.swing.JTextArea();
- Proses = new javax.swing.JButton();
- keluar = new javax.swing.JButton();
- bersih = new javax.swing.JButton();
- jLabel6 = new javax.swing.JLabel();
- tanggal = new javax.swing.JTextField();
- jenis = new javax.swing.JComboBox<>();
- jButton3.setText("jButton3");
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setName("jenis kelamin"); // NOI18N
- jLabel1.setText("Biodata Siswa SMK MANDALAHAYU");
- jLabel2.setText("No.Siswa :");
- jLabel3.setText("Nama Siswa :");
- jLabel4.setText("Jenis Kelamin :");
- nama.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- namaActionPerformed(evt);
- }
- });
- jLabel5.setText("Alamat Siswa :");
- biodata.setColumns(20);
- biodata.setRows(5);
- jScrollPane1.setViewportView(biodata);
- Proses.setText("Proses");
- Proses.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- ProsesActionPerformed(evt);
- }
- });
- keluar.setText("Keluar");
- keluar.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- keluarActionPerformed(evt);
- }
- });
- bersih.setText("Bersih");
- bersih.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- bersihActionPerformed(evt);
- }
- });
- jLabel6.setText("Tanggal Lahir :");
- jenis.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Laki-Laki", "Perempuan" }));
- jenis.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jenisActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(127, 127, 127)
- .addComponent(jLabel1)
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGap(24, 24, 24)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
- .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(nama)
- .addComponent(alamat)
- .addComponent(no)
- .addComponent(tanggal)
- .addComponent(jenis, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGap(10, 10, 10)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(28, 28, 28))
- .addGroup(layout.createSequentialGroup()
- .addComponent(bersih)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(Proses)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(keluar)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(no, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(nama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel5)
- .addComponent(alamat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel4)
- .addComponent(jenis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel6)
- .addComponent(tanggal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(46, 46, 46)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(bersih)
- .addComponent(Proses)
- .addComponent(keluar))
- .addContainerGap(44, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void ProsesActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- biodata(nama text area kalian tdi).setText("\n no \t: "+no(nama text filed kalian).getText()+"\n nama siswa(nama text filed kalian) \t: "+nama.getText()
- +"\n Jenis Kelamin(nama combo box kalian) \t: "+ jenis.getSelectedItem()
- +"\n Alamat : "+ alamat(nama text filed kalian).getText()
- +"\n Tanggal Lahir : "+ tanggal(nama text filed kalian).getText());
- }
- private void keluarActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- System.exit(0);
- }
- private void bersihActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- nama.setText("");
- no.setText("");
- tanggal.setText("");
- alamat.setText("");
- biodata.setText("");
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new projectbiodata().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton Proses;
- private javax.swing.JTextField alamat;
- private javax.swing.JButton bersih;
- private javax.swing.JTextArea biodata;
- private javax.swing.JButton jButton3;
- 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.JLabel jLabel6;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JComboBox<String> jenis;
- private javax.swing.JButton keluar;
- private javax.swing.JTextField nama;
- private javax.swing.JTextField no;
- private javax.swing.JTextField tanggal;
- // End of variables declaration
- }
Keterangan : Sebenarnya nomer 30 - 177 itu tidak terlalu penting jadi kalian tidak usah pusing mengapa kaya gini dan seperti ini, karena nomer 30 - 177 itu termasuk data desaign yang tadi kita buat. Tetapi jikalau kalian ingin memahaminya lebih lanjut tidak apa-apa....intinya buat belajar :)
Tidak ada komentar:
Posting Komentar