Jumat, 02 November 2018

cara membuat biodata menggunakan GUI


- 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

  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package biodata_siswa;

  7. /**
  8. *
  9. * @author Rei Fandi
  10.  */
  11. public class projectbiodata extends javax.swing.JFrame {

  12. /**
  13.   * Creates new form projectbiodata
  14. */
  15. public projectbiodata() {
  16. initComponents();

  17. }

  18. /**
  19. * This method is called from within the constructor to initialize the form.
  20. * WARNING: Do NOT modify this code. The content of this method is always
  21. * regenerated by the Form Editor.
  22. */
  23. @SuppressWarnings("unchecked")
  24. // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  25. private void initComponents() {
  26.         jButton3 = new javax.swing.JButton();
  27.         jLabel1 = new javax.swing.JLabel();
  28.         jLabel2 = new javax.swing.JLabel();
  29.         jLabel3 = new javax.swing.JLabel();
  30.         jLabel4 = new javax.swing.JLabel();
  31.         no = new javax.swing.JTextField();
  32.         nama = new javax.swing.JTextField();
  33.         alamat = new javax.swing.JTextField();
  34.         jLabel5 = new javax.swing.JLabel();
  35.         jScrollPane1 = new javax.swing.JScrollPane();
  36.         biodata = new javax.swing.JTextArea();
  37.         Proses = new javax.swing.JButton();
  38.         keluar = new javax.swing.JButton();
  39.         bersih = new javax.swing.JButton();
  40.         jLabel6 = new javax.swing.JLabel();
  41.         tanggal = new javax.swing.JTextField();
  42.         jenis = new javax.swing.JComboBox<>();

  43.         jButton3.setText("jButton3");

  44.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  45.         setName("jenis kelamin"); // NOI18N

  46.         jLabel1.setText("Biodata Siswa SMK MANDALAHAYU");

  47.         jLabel2.setText("No.Siswa :");

  48.         jLabel3.setText("Nama Siswa :");

  49.         jLabel4.setText("Jenis Kelamin :");

  50.         nama.addActionListener(new java.awt.event.ActionListener() {
  51.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  52.                 namaActionPerformed(evt);
  53.             }
  54.         });

  55.         jLabel5.setText("Alamat Siswa :");

  56.         biodata.setColumns(20);
  57.         biodata.setRows(5);
  58.         jScrollPane1.setViewportView(biodata);

  59.         Proses.setText("Proses");
  60.         Proses.addActionListener(new java.awt.event.ActionListener() {
  61.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  62.                 ProsesActionPerformed(evt);
  63.             }
  64.         });

  65.         keluar.setText("Keluar");
  66.         keluar.addActionListener(new java.awt.event.ActionListener() {
  67.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  68.                 keluarActionPerformed(evt);
  69.             }
  70.         });

  71.         bersih.setText("Bersih");
  72.         bersih.addActionListener(new java.awt.event.ActionListener() {
  73.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  74.                 bersihActionPerformed(evt);
  75.             }
  76.         });

  77.         jLabel6.setText("Tanggal Lahir :");

  78.         jenis.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Laki-Laki", "Perempuan" }));
  79.         jenis.addActionListener(new java.awt.event.ActionListener() {
  80.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  81.                 jenisActionPerformed(evt);
  82.             }
  83.         });

  84.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  85.         getContentPane().setLayout(layout);
  86.         layout.setHorizontalGroup(
  87.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  88.             .addGroup(layout.createSequentialGroup()
  89.                 .addGap(127, 127, 127)
  90.                 .addComponent(jLabel1)
  91.                 .addGap(0, 0, Short.MAX_VALUE))
  92.             .addGroup(layout.createSequentialGroup()
  93.                 .addGap(24, 24, 24)
  94.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  95.                     .addGroup(layout.createSequentialGroup()
  96.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  97.                             .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
  98.                             .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
  99.                             .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  100.                             .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  101.                             .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING))
  102.                         .addGap(18, 18, 18)
  103.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  104.                             .addComponent(nama)
  105.                             .addComponent(alamat)
  106.                             .addComponent(no)
  107.                             .addComponent(tanggal)
  108.                             .addComponent(jenis, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  109.                         .addGap(10, 10, 10)
  110.                         .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  111.                         .addGap(28, 28, 28))
  112.                     .addGroup(layout.createSequentialGroup()
  113.                         .addComponent(bersih)
  114.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  115.                         .addComponent(Proses)
  116.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  117.                         .addComponent(keluar)
  118.                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  119.         );
  120.         layout.setVerticalGroup(
  121.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  122.             .addGroup(layout.createSequentialGroup()
  123.                 .addContainerGap()
  124.                 .addComponent(jLabel1)
  125.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  126.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  127.                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  128.                     .addGroup(layout.createSequentialGroup()
  129.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  130.                             .addComponent(jLabel2)
  131.                             .addComponent(no, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  132.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  133.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  134.                             .addComponent(jLabel3)
  135.                             .addComponent(nama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  136.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  137.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  138.                             .addComponent(jLabel5)
  139.                             .addComponent(alamat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  140.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  141.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  142.                             .addComponent(jLabel4)
  143.                             .addComponent(jenis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
  144.                 .addGap(18, 18, 18)
  145.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  146.                     .addComponent(jLabel6)
  147.                     .addComponent(tanggal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  148.                 .addGap(46, 46, 46)
  149.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  150.                     .addComponent(bersih)
  151.                     .addComponent(Proses)
  152.                     .addComponent(keluar))
  153.                 .addContainerGap(44, Short.MAX_VALUE))
  154.         );

  155.         pack();
  156.     }// </editor-fold>                        

  157.     private void ProsesActionPerformed(java.awt.event.ActionEvent evt) {                                       
  158.         // TODO add your handling code here:
  159.         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()
  160.                 +"\n Jenis Kelamin(nama combo box kalian) \t: "+ jenis.getSelectedItem()
  161.                 +"\n Alamat : "+ alamat(nama text filed kalian).getText()
  162.                 +"\n Tanggal Lahir : "+ tanggal(nama text filed kalian).getText());
  163.     }                                      

  164.     private void keluarActionPerformed(java.awt.event.ActionEvent evt) {                                       
  165.         // TODO add your handling code here:
  166.         System.exit(0);
  167.     }                                      

  168.     private void bersihActionPerformed(java.awt.event.ActionEvent evt) {                                       
  169.         // TODO add your handling code here:
  170.         nama.setText("");
  171.         no.setText("");
  172.         tanggal.setText("");
  173.         alamat.setText("");
  174.         biodata.setText("");
  175.     }                                      

  176.     /**
  177.      * @param args the command line arguments
  178.      */
  179.     public static void main(String args[]) {
  180.         /* Set the Nimbus look and feel */
  181.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  182.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  183.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
  184.          */
  185.         try {
  186.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  187.                 if ("Nimbus".equals(info.getName())) {
  188.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  189.                     break;
  190.                 }
  191.             }
  192.         } catch (ClassNotFoundException ex) {
  193.             java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  194.         } catch (InstantiationException ex) {
  195.             java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  196.         } catch (IllegalAccessException ex) {
  197.             java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  198.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  199.             java.util.logging.Logger.getLogger(projectbiodata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  200.         }
  201.         //</editor-fold>

  202.         /* Create and display the form */
  203.         java.awt.EventQueue.invokeLater(new Runnable() {
  204.             public void run() {
  205.                 new projectbiodata().setVisible(true);
  206.             }
  207.         });
  208.     }

  209.     // Variables declaration - do not modify                     
  210.     private javax.swing.JButton Proses;
  211.     private javax.swing.JTextField alamat;
  212.     private javax.swing.JButton bersih;
  213.     private javax.swing.JTextArea biodata;
  214.     private javax.swing.JButton jButton3;
  215.     private javax.swing.JLabel jLabel1;
  216.     private javax.swing.JLabel jLabel2;
  217.     private javax.swing.JLabel jLabel3;
  218.     private javax.swing.JLabel jLabel4;
  219.     private javax.swing.JLabel jLabel5;
  220.     private javax.swing.JLabel jLabel6;
  221.     private javax.swing.JScrollPane jScrollPane1;
  222.     private javax.swing.JComboBox<String> jenis;
  223.     private javax.swing.JButton keluar;
  224.     private javax.swing.JTextField nama;
  225.     private javax.swing.JTextField no;
  226.     private javax.swing.JTextField tanggal;
  227.     // End of variables declaration                   
  228. }





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

Cara menggubah No Telfon di bpjs kesehatan

Cara mengubah no telfon di Bpjs Kesehatan 1. Anda harus menghubungi PANDAWA 2. Anda bakal dialihkan ke no wa bpjs kesehatan, lalu anda ketik...