Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package flippjar;
- import java.util.*;
- import java.awt.*;
- import javax.swing.*;
- import java.awt.event.*;
- import java.util.concurrent.TimeUnit;
- import java.io.*;
- class FlippGUI extends JFrame implements ActionListener {
- private JButton button, button2;
- private JLabel label, label2;
- private JTextField text, text2;
- private String username = "";
- private String password = "";
- private String[] line, line2 = new String[6];
- private String[] name = new String[6];
- private String[] pswd = new String[6];
- public FlippGUI() throws IOException {
- Scanner key = new Scanner(System.in);
- setTitle("Flipp Systems Login");
- setLayout(null);
- setSize(500, 250);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- getContentPane().setBackground(null);
- setVisible(true);
- text = new JTextField(20);
- text.setLocation(195, 73);
- text.setText("Username");
- text.setSize(120, 17);
- text2 = new JTextField(20);
- text2.setLocation(195, 102);
- text2.setText("Password");
- text2.setSize(120, 17);
- label = new JLabel("Please enter a password: ");
- label.setLocation(30, 60);
- label.setSize(300, 100);
- label.setForeground(Color.black);
- label.setFont(new Font("Arial", Font.PLAIN, 14));
- label2 = new JLabel("Please enter a username: ");
- label2.setLocation(30, 30);
- label2.setSize(300, 100);
- label2.setForeground(Color.black);
- label2.setFont(new Font("Arial", Font.PLAIN, 14));
- button = new JButton("Enter");
- button.setLocation(375, 200);
- button.setSize(100, 15);
- button.addActionListener(this);
- button2 = new JButton("Exit");
- button2.setLocation(25, 200);
- button2.setSize(100, 15);
- button2.addActionListener(this);
- getContentPane().add(button);
- getContentPane().add(button2);
- getContentPane().add(label);
- getContentPane().add(text);
- getContentPane().add(label2);
- getContentPane().add(text2);
- File u = new File("usernames.txt");
- Scanner numScan = new Scanner(u);
- File p = new File("passwords.txt");
- Scanner numScan2 = new Scanner(p);
- do {
- for(int j = 0;j < 6;j++) {
- line[j] = numScan.nextLine();
- line2[j] = numScan2.nextLine();
- }
- }while(numScan.hasNextLine() && numScan2.hasNextLine());
- }
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == button) {
- username = text.getText();
- password = text2.getText();
- if(username.equals(line)) {
- if(password.equals(line2)) {
- JOptionPane.showMessageDialog(null, "Welcome!");
- return;
- }
- }
- }
- if(e.getSource() == button) {
- username = text.getText();
- password = text2.getText();
- if(username.equals(line)) {
- if(!password.equals(line2)) {
- JOptionPane.showMessageDialog(null, "Incorrect password!");
- return;
- }
- }
- }
- if(e.getSource() == button) {
- username = text.getText();
- password = text2.getText();
- if(!username.equals(line)) {
- JOptionPane.showMessageDialog(null, "Incorrect username!");
- }
- }
- }
- }
- public class FlippJar {
- public static void main(String args[]) throws IOException {
- FlippGUI applet = new FlippGUI();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement