tugas java login

Tugas java 

   disusun : Fajar Nugroho
   Nim      : 123090160
   plug      : 8

===============================================

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package login;

/**
 *
 * @author ganjur
 */


import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;


class frame extends JFrame implements ActionListener{
JLabel Luser = new JLabel("User");
JLabel Lpass = new JLabel("Password");
JPasswordField Ppass = new JPasswordField(20);
JTextField Tuser = new JTextField(20);
JButton bok = new JButton("OK");
JButton bcancel = new JButton("Cancel");
public frame( String Judul ){

add(Luser);
add(Tuser);
add(Lpass);
add(Ppass);
add(bok);
add(bcancel);
setVisible(true);
setSize(300, 150);
setLayout(null);
setDefaultCloseOperation(3);
setTitle(Judul);
setLayout(new FlowLayout());
bok.addActionListener(this);
bcancel.addActionListener(this);


}

public void actionPerformed(ActionEvent ae) {


if(ae.getSource() == bok) {
if(Tuser.getText().equals("123090160")&&Ppass.getText().equals("java2"))
JOptionPane.showMessageDialog(this, "Login Berhasil,\n" +
"", "message",
JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(this, "Login Gagal,\n" +
"silahkan coba lagi", "message",
JOptionPane.INFORMATION_MESSAGE);
Tuser.setText("");
Ppass.setText("");

}
if(ae.getSource()==bcancel){
closeWindow();
}
}
private void closeWindow() {
switch (JOptionPane.showConfirmDialog(this, "weee mau exit?")) {
case JOptionPane.YES_OPTION:
System.out.println("Yes!");
System.exit(0);
break;
case JOptionPane.NO_OPTION:
System.out.println("No!");
break;
case JOptionPane.CANCEL_OPTION:
System.out.println("Cancel!");
break;
case JOptionPane.CLOSED_OPTION:
System.out.println("Tidak dijawab!");
}
}
}
public class Login {
public static void main(String[] args) {
frame p = new frame("Login Form");

}
}


OUTPUT :













0 Response to "tugas java login"

Posting Komentar

powered by Blogger | WordPress by Newwpthemes | Converted by BloggerTheme