SHARE
TWEET

Untitled

a guest Sep 4th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. class Mywindow extends Frame implements ActionListener
  5. {
  6.  Label  luser,lpass,lmsg;
  7.  TextField tuser,tpass;
  8.  Button bok,bcancel;
  9.  Mywindow()
  10. {
  11.  luser=new Label("username");
  12.  lpass=new Label("password");
  13.  lmsg=new Label(" ");
  14.  tuser=new TextField();
  15.  tpass=new TextField();
  16.  bok=new Button("ok");
  17.  bcancel= new Button("cancel");
  18.  luser.setBounds(25,100,70,25);
  19.  lpass.setBounds(120,180,180,25);
  20.  tuser.setBounds(90,310,200,25);
  21.  tpass.setBounds(120,100,180,25);
  22.  lmsg.setBounds(90,310,200,25);
  23.  add(luser);
  24.  add(lpass);
  25.  add(tuser);
  26.  add(tpass);
  27.  add(lmsg);
  28.  bok.setBounds(60,280,80,30);
  29.  bcancel.setBounds(200,280,80,30);
  30.  bok.addActionListener(this);
  31.  bcancel.addActionListener(this);
  32.  add(bok);
  33.  add(bcancel);
  34.  setSize(400,350);
  35.  setLayout(null);
  36.  setVisible(true);
  37. }
  38. public void actionPerformed(ActionEvent e)
  39. {
  40.  String s1=tuser.getText();
  41.  String s2=tpass.getText();
  42.  String command=(( Button) e.getSource()).getActionCommand();
  43.  if(command.equals("ok"))
  44.  {
  45.   if(s1.equals("awt")&&s2.equals("java"))
  46.   {
  47.     luser.setVisible(false);
  48.     lpass.setVisible(false);
  49.     tuser.setVisible(false);
  50.     tpass.setVisible(false);
  51.     bcancel.setBounds(160,175,80,30);
  52.     lmsg.setForeground(Color.green);
  53.     lmsg.setText("succesfull login");
  54.   }
  55.  else
  56.  {
  57.    lmsg.setForeground(Color.red);
  58.    lmsg.setText("invalid user name and password");
  59.   }
  60. }
  61.  else
  62.  {
  63.    System.exit(0);
  64.  }
  65. }
  66. public static void main(String[] args){
  67.  Mywindow mw=new Mywindow();
  68. }
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top