SHARE
TWEET

Untitled

a guest Jan 21st, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.BorderLayout;
  2. import java.awt.EventQueue;
  3.  
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.border.EmptyBorder;
  7. import javax.swing.JLabel;
  8. import javax.swing.JOptionPane;
  9. import javax.swing.JTextField;
  10. import javax.swing.JPasswordField;
  11. import javax.swing.JButton;
  12. import java.awt.event.ActionListener;
  13. import java.awt.event.ActionEvent;
  14.  
  15. public class Ventana1 extends JFrame {
  16.  
  17.     private JPanel contentPane;
  18.     public static JTextField txt_usuario;
  19.     public static JPasswordField pss_contraseña;
  20.  
  21.  
  22.     public Ventana1() {
  23.         setTitle("Contrase\u00F1a");
  24.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  25.         setBounds(100, 100, 450, 300);
  26.         contentPane = new JPanel();
  27.         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  28.         setContentPane(contentPane);
  29.         contentPane.setLayout(null);
  30.  
  31.         JLabel lblUsuario = new JLabel("Usuario:");
  32.         lblUsuario.setBounds(36, 28, 45, 13);
  33.         contentPane.add(lblUsuario);
  34.  
  35.         JLabel lblPassword = new JLabel("Password:");
  36.         lblPassword.setBounds(36, 106, 45, 13);
  37.         contentPane.add(lblPassword);
  38.  
  39.         txt_usuario = new JTextField();
  40.         txt_usuario.setBounds(151, 25, 96, 19);
  41.         contentPane.add(txt_usuario);
  42.         txt_usuario.setColumns(10);
  43.  
  44.         pss_contraseña = new JPasswordField();
  45.         pss_contraseña.setBounds(151, 106, 96, 19);
  46.         contentPane.add(pss_contraseña);
  47.  
  48.  
  49.         final DatosUsuario data = new DatosUsuario();
  50.         final Ventana2 window2=new Ventana2();
  51.  
  52.  
  53.  
  54.         JButton btnEntrar = new JButton("Entrar");
  55.         btnEntrar.addActionListener(new ActionListener() {
  56.             public void actionPerformed(ActionEvent e) {
  57.                 if(data.probarPass()==1)
  58.                 {
  59.                     JOptionPane.showMessageDialog(null, "Bienvenido al sistema");
  60.                     window2.setVisible(true);
  61.                     dispose();
  62.                 }
  63.                 else {
  64.                     JOptionPane.showMessageDialog(null, "Error usu o pw incorrecta");
  65.                 }
  66.             }
  67.         });
  68.         btnEntrar.setBounds(53, 206, 85, 21);
  69.         contentPane.add(btnEntrar);
  70.  
  71.         JButton btnSalir = new JButton("Salir");
  72.         btnSalir.addActionListener(new ActionListener() {
  73.             public void actionPerformed(ActionEvent e) {
  74.                 System.exit(0);
  75.             }
  76.         });
  77.         btnSalir.setBounds(250, 206, 85, 21);
  78.         contentPane.add(btnSalir);
  79.     }
  80. }
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