SHARE
TWEET

Untitled

a guest Sep 4th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. class MyWindow extends Frame implements ActionListener
  4. {
  5. Label luser,lpass,lmsg;
  6. TextField tuser,tpass;
  7. Button bok,bcancel;
  8. MyWindow(){
  9. luser=new Label("Username");
  10. lpass=new Label("password");
  11. lmsg=new Label(" ");
  12. tuser=new TextField();
  13. tpass=new TextField();
  14. bok=new Button("ok");
  15. bcancel=new Button("cancel");
  16. luser.setBounds(25,100,70,25);
  17. lpass.setBounds(25,180,70,25);
  18. tuser.setBounds(120,100,180,25);
  19. tpass.setBounds(120,180,180,25);
  20. lmsg.setBounds(90,310,200,25);
  21. add(luser);
  22. add(lpass);
  23. add(lmsg);
  24. add(tuser);
  25. add(tpass);
  26.  
  27. bok.setBounds(60,280,80,30);
  28. bcancel.setBounds(200,280,80,30);
  29. bok.addActionListener(this);
  30. bcancel.addActionListener(this);
  31. add(bok);
  32. add(bcancel);
  33. setSize(400,350);
  34. setLayout(null);
  35. setVisible(true);
  36. }
  37.  
  38. public void actionPerformed(ActionEvent e){
  39. String s1=tuser.getText();
  40. String s2=tpass.getText();
  41. String command=((Button)e.getSource()).getActionCommand();
  42.  
  43. if(command.equals("ok")){
  44.  
  45. if((s1.equals("awt"))&&(s2.equals("java"))){
  46. luser.setVisible(false);
  47. lpass.setVisible(false);
  48. tuser.setVisible(false);
  49. tpass.setVisible(false);
  50. bok.setVisible(false);
  51. bcancel.setBounds(165,175,80,30);
  52. lmsg.setForeground(Color.green);
  53. lmsg.setText("successful login");
  54. } else{
  55. lmsg.setForeground(Color.red);
  56. lmsg.setText("Invalid Username&Password");
  57. }
  58. }else{
  59. System.exit(0);
  60. }
  61. }
  62.  
  63. public static void main(String[]args){
  64. MyWindow mw=new MyWindow();
  65. }
  66. }
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