Minggu, 18 November 2018

codingan NetBeans untuk membuat login



Desain Login




Keterangan :
  •  Untuk kolom Nama kalian menggunakan Text Field.
  •  Untuk kolom Password kalian menggunakan Password Field.
  •  Untuk tombol login dan keluar kalian menggunakan Button.
Setelah kalian membuat desain login 

- Langkah awal kalian harus klik kanan pada Text Field, dan Button satu per-satu tidak boleh berbarengan..
- Setelah itu pilih Change Variable Name...
- Lalu ubah nama menjadi :

Text Field : nama
Password Field : password
Button : login
Button : keluar


Dibawah ini adalah Codingan Login
  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 desaignlogin extends javax.swing.JFrame {

  12.     /**
  13.      * Creates new form desaignlogin
  14.      */
  15.     public desaignlogin() {
  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.         jLabel1 = new javax.swing.JLabel();
  27.         jLabel2 = new javax.swing.JLabel();
  28.         jLabel3 = new javax.swing.JLabel();
  29.         nama = new javax.swing.JTextField();
  30.         login = new javax.swing.JButton();
  31.         keluar = new javax.swing.JButton();
  32.         password = new javax.swing.JPasswordField();

  33.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

  34.         jLabel1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
  35.         jLabel1.setText("\" Login \"");
  36.         jLabel1.setAlignmentY(10.0F);
  37.         jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

  38.         jLabel2.setText("Nama :");

  39.         jLabel3.setText("Password :");

  40.         login.setText("Login");
  41.         login.addActionListener(new java.awt.event.ActionListener() {
  42.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  43.                 loginActionPerformed(evt);
  44.             }
  45.         });

  46.         keluar.setText("Keluar");
  47.         keluar.addActionListener(new java.awt.event.ActionListener() {
  48.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  49.                 keluarActionPerformed(evt);
  50.             }
  51.         });

  52.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  53.         getContentPane().setLayout(layout);
  54.         layout.setHorizontalGroup(
  55.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  56.             .addGroup(layout.createSequentialGroup()
  57.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  58.                     .addGroup(layout.createSequentialGroup()
  59.                         .addGap(24, 24, 24)
  60.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  61.                             .addComponent(jLabel3)
  62.                             .addComponent(jLabel2)
  63.                             .addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
  64.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  65.                             .addGroup(layout.createSequentialGroup()
  66.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  67.                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  68.                                     .addComponent(nama, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
  69.                                     .addComponent(password)))
  70.                             .addGroup(layout.createSequentialGroup()
  71.                                 .addGap(24, 24, 24)
  72.                                 .addComponent(keluar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))))
  73.                     .addGroup(layout.createSequentialGroup()
  74.                         .addGap(127, 127, 127)
  75.                         .addComponent(jLabel1)))
  76.                 .addContainerGap(155, Short.MAX_VALUE))
  77.         );
  78.         layout.setVerticalGroup(
  79.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  80.             .addGroup(layout.createSequentialGroup()
  81.                 .addContainerGap()
  82.                 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
  83.                 .addGap(17, 17, 17)
  84.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  85.                     .addComponent(jLabel2)
  86.                     .addComponent(nama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  87.                 .addGap(18, 18, 18)
  88.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  89.                     .addComponent(jLabel3)
  90.                     .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  91.                 .addGap(27, 27, 27)
  92.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  93.                     .addComponent(login)
  94.                     .addComponent(keluar))
  95.                 .addContainerGap(121, Short.MAX_VALUE))
  96.         );

  97.         pack();
  98.     }// </editor-fold>                        

  99.     private void loginActionPerformed(java.awt.event.ActionEvent evt) {                                      
  100.         // TODO add your handling code here:
  101.         String user = "laras";
  102.             String pas = "12345";
  103.             String username = nama.getText();
  104.             String pasword = password.getText();
  105.             if (nama.equals(nama)&&password.equals(password)){
  106.                    this.setVisible(false);
  107.                    new projectbiodata()(nama data yang akan kalian panggil).setVisible(true);
  108.             } else {
  109.                 javax.swing.JOptionPane.showMessageDialog(null, "Maaf user bame atau" +"Password anda salah");
  110.                 nama.setText("");
  111.                 password.setText("");
  112.                 nama.requestFocus();
  113.             
  114.             }
  115.     }                                     

  116.     private void keluarActionPerformed(java.awt.event.ActionEvent evt) {                                       
  117.         // TODO add your handling code here:
  118.         System.exit(0);
  119.     }                                      

  120.     /**
  121.      * @param args the command line arguments
  122.      */
  123.     public static void main(String args[]) {
  124.         /* Set the Nimbus look and feel */
  125.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  126.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  127.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
  128.          */
  129.         try {
  130.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  131.                 if ("Nimbus".equals(info.getName())) {
  132.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  133.                     break;
  134.                 }
  135.             }
  136.         } catch (ClassNotFoundException ex) {
  137.             java.util.logging.Logger.getLogger(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  138.         } catch (InstantiationException ex) {
  139.             java.util.logging.Logger.getLogger(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  140.         } catch (IllegalAccessException ex) {
  141.             java.util.logging.Logger.getLogger(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  142.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  143.             java.util.logging.Logger.getLogger(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  144.         }
  145.         //</editor-fold>

  146.         /* Create and display the form */
  147.         java.awt.EventQueue.invokeLater(new Runnable() {
  148.             public void run() {
  149.                 new desaignlogin().setVisible(true);
  150.             }
  151.         });
  152.     }

  153.     // Variables declaration - do not modify                     
  154.     private javax.swing.JLabel jLabel1;
  155.     private javax.swing.JLabel jLabel2;
  156.     private javax.swing.JLabel jLabel3;
  157.     private javax.swing.JButton keluar;
  158.     private javax.swing.JButton login;
  159.     private javax.swing.JTextField nama;
  160.     private javax.swing.JPasswordField password;
  161.     // End of variables declaration                   
  162. }



NOTE : Nomer 27 - 111 dan 140 - 168 jangan terlalu diperhatikan ya guys soalnya disana tidak terlalu penting
jdi kalian harus memperhatikan nomer 6,12,17,18 dan 112-133 saja ya...dari pada kalian pusing melihat tulisan semua kan kgk asik :) wkwk. Dan satu lagi jika ada tulisan berwarna merah jangan diketik ya guys itu bukan codingan tetapi pernyataan :)



" Semoga Bermanfaat "



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...