Desain Login
- 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..
- 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
Password Field : password
Button : login
Button : keluar
Dibawah ini adalah Codingan Login
- /*
- * 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 desaignlogin extends javax.swing.JFrame {
- /**
- * Creates new form desaignlogin
- */
- public desaignlogin() {
- 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() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- nama = new javax.swing.JTextField();
- login = new javax.swing.JButton();
- keluar = new javax.swing.JButton();
- password = new javax.swing.JPasswordField();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
- jLabel1.setText("\" Login \"");
- jLabel1.setAlignmentY(10.0F);
- jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- jLabel2.setText("Nama :");
- jLabel3.setText("Password :");
- login.setText("Login");
- login.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- loginActionPerformed(evt);
- }
- });
- keluar.setText("Keluar");
- keluar.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- keluarActionPerformed(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()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(24, 24, 24)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel3)
- .addComponent(jLabel2)
- .addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(nama, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
- .addComponent(password)))
- .addGroup(layout.createSequentialGroup()
- .addGap(24, 24, 24)
- .addComponent(keluar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addGroup(layout.createSequentialGroup()
- .addGap(127, 127, 127)
- .addComponent(jLabel1)))
- .addContainerGap(155, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(17, 17, 17)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(nama, 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.BASELINE)
- .addComponent(jLabel3)
- .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(27, 27, 27)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(login)
- .addComponent(keluar))
- .addContainerGap(121, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void loginActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- String user = "laras";
- String pas = "12345";
- String username = nama.getText();
- String pasword = password.
getText(); - if (nama.equals(nama)&&password.equals(password)){
- this.setVisible(false);
- new projectbiodata()(nama data yang akan kalian panggil).setVisible(true);
- } else {
- javax.swing.JOptionPane.showMessageDialog(null, "Maaf user bame atau" +"Password anda salah");
- nama.setText("");
- password.setText("");
- nama.requestFocus();
- }
- }
- private void keluarActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- System.exit(0);
- }
- /**
- * @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(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(desaignlogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(desaignlogin.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 desaignlogin().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JButton keluar;
- private javax.swing.JButton login;
- private javax.swing.JTextField nama;
- private javax.swing.JPasswordField password;
- // End of variables declaration
- }
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