Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package passwordmanager;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- @SuppressWarnings("serial")
- public class Frame extends JFrame
- {
- JLabel username;
- JLabel password;
- JTextField user;
- JPasswordField pass;
- JButton login;
- public Frame()
- {
- //Frame
- setLayout(null);
- setLocationRelativeTo(null);
- setResizable(false);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setSize(425, 300);
- setVisible(true);
- setTitle("Password-Login");
- //Label 1
- username = new JLabel("Benutzernahme:");
- username.setBounds(16, 50, 500, 15);
- //Font
- Font font1 = new Font("", Font.BOLD, 13);
- username.setFont(font1);
- add(username);
- //Label2
- password = new JLabel("Passwort:");
- password.setBounds(16, 134, 200, 20);
- password.setFont(font1);
- add(password);
- //TextField
- user = new JTextField();
- user.setBounds(16, 76, 350, 30);
- user.setVisible(true);
- add(user);
- //PasswordField
- pass = new JPasswordField();
- pass.setBounds(16, 160, 350, 30);
- pass.setVisible(true);
- add(pass);
- //Button
- login = new JButton();
- login.setBounds(0, 0, 5, 5);
- add(login);
- }
- String myusername = user.getText();
- String mypassword = new String(pass.getPassword());
- public class Listener implements ActionListener
- {
- public void actionPerformed(ActionEvent e)
- {
- if(myusername.equalsIgnoreCase("whatever") && mypassword.equalsIgnoreCase("whatever"))
- {
- System.out.println("NICE");
- }
- }
- }
- }
- String myusername = user.getText();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement