Advertisement
Guest User

Untitled

a guest
Jul 10th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. public class Log extends JFrame {
  6.  
  7. public static void main(String[] args) {
  8. Log frameTabel = new Log();
  9. }
  10.  
  11. JButton blogin = new JButton("Login");
  12. JPanel panel = new JPanel();
  13. JTextField txuser = new JTextField(15);
  14. JPasswordField pass = new JPasswordField(15);
  15.  
  16. Log(){
  17. super("Login Autentification");
  18. setSize(300,200);
  19. setLocation(500,280);
  20. panel.setLayout (null);
  21.  
  22.  
  23. txuser.setBounds(70,30,150,20);
  24. pass.setBounds(70,65,150,20);
  25. blogin.setBounds(110,100,80,20);
  26.  
  27. panel.add(blogin);
  28. panel.add(txuser);
  29. panel.add(pass);
  30.  
  31. getContentPane().add(panel);
  32. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  33. setVisible(true);
  34. actionlogin();
  35. }
  36.  
  37. public void actionlogin(){
  38. blogin.addActionListener(new ActionListener() {
  39. public void actionPerformed(ActionEvent ae) {
  40. String puname = txuser.getText();
  41. String ppaswd = pass.getText();
  42. if(puname.equals("test") && ppaswd.equals("12345")) {
  43. newframe regFace =new newframe();
  44. regFace.setVisible(true);
  45. dispose();
  46. } else {
  47.  
  48. JOptionPane.showMessageDialog(null,"Wrong Password / Username");
  49. txuser.setText("");
  50. pass.setText("");
  51. txuser.requestFocus();
  52. }
  53.  
  54. }
  55. });
  56. }
  57. }
  58.  
  59. and you must save this source below with name "newframe.java"
  60.  
  61.  
  62. import javax.swing.*;
  63. import java.awt.*;
  64. import java.awt.event.*;
  65.  
  66.  
  67. public class newframe extends JFrame {
  68.  
  69. public static void main(String[] args) {
  70. newframe frameTabel = new newframe();
  71. }
  72.  
  73. JLabel welcome = new JLabel("Welcome to a New Frame");
  74. JPanel panel = new JPanel();
  75.  
  76. newframe(){
  77. super("Welcome");
  78. setSize(300,200);
  79. setLocation(500,280);
  80. panel.setLayout (null);
  81.  
  82. welcome.setBounds(70,50,150,60);
  83.  
  84. panel.add(welcome);
  85.  
  86. getContentPane().add(panel);
  87. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  88. setVisible(true);
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement