You are on page 1of 3

Nama : M.Iskandar Wijaya Kelas : TI 09 D Npm : 09312054 public class inputmasuk extends javax.swing.

JFrame { public String nama; public String pass; public String name; public String masuk; /** Creates new form inputmasuk */ public inputmasuk() { 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(); jtfnama = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jtfpass = new javax.swing.JPasswordField(); btmasuk = new javax.swing.JButton(); btkeluar = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText("Nama"); jtfnama.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jtfnamaActionPerformed(evt); } }); jLabel2.setText("Password"); btmasuk.setText("Masuk"); btmasuk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btmasukActionPerformed(evt); } });

btkeluar.setText("Keluar"); btkeluar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btkeluarActionPerformed(evt); } }); private void jtfnamaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btkeluarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { int jawab = JOptionPane.showConfirmDialog(this, "apakah anda yakin mau keluar ?","form keluar",JOptionPane.YES_NO_OPTION,JOptionPane.PLAIN_MESSAGE); if (jawab == JOptionPane.YES_OPTION) { dispose(); } } catch (Exception e) { } } private void btmasukActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try{ name = "enda"; masuk = "5043"; nama = jtfnama.getText(); pass = jtfpass.getText(); if (nama.equals("")&&pass.equals("")){ jtfnama.requestFocus(); JOptionPane.showMessageDialog(null, "username dan password diisikan terlebih dahulu","Information",JOptionPane.INFORMATION_MESSAGE); } else if (nama.equals("")){ jtfnama.requestFocus(); JOptionPane.showMessageDialog(null, "username harus terisi","eror massage",JOptionPane.INFORMATION_MESSAGE); } else if (pass.equals("")){ jtfpass.requestFocus(); JOptionPane.showMessageDialog(null, "password harus terisis....","eror massage",JOptionPane.INFORMATION_MESSAGE); }

else if (pass.equals("5043")&&nama.equals("enda")){ penambahannilai pn = new penambahannilai(); pn.setVisible(true); this.dispose(); } else { jtfnama.requestFocus(); jtfnama.setText(""); jtfpass.setText(""); JOptionPane.showMessageDialog(null, "harus di isi keduanya dengan benar ya..... ^_^","Information",JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e){ } } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new inputmasuk().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btkeluar; private javax.swing.JButton btmasuk; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JTextField jtfnama; private javax.swing.JPasswordField jtfpass; // End of variables declaration }\