-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasswordManager.java
More file actions
106 lines (76 loc) · 2.89 KB
/
Copy pathpasswordManager.java
File metadata and controls
106 lines (76 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package JFrames;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.*;
import javax.swing.*;
import java.util.Scanner;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.swing.border.Border;
import javax.swing.BorderFactory;
public class pleasehelpmeimgonnadie {
private JFrame ourFrame = new JFrame("Password Manager");
pleasehelpmeimgonnadie(){
ourFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ourFrame.setBounds(200, 100, 400, 300);
Container container = ourFrame.getContentPane();
container.setLayout(null);
JLabel logo = new JLabel("Enter Email and Password into Boxes");
logo.setBounds(110,5,250,30);
JLabel email_label = new JLabel("Email :");
email_label.setBounds(40,30,250,30);
JLabel password_label = new JLabel("Password :");
password_label.setBounds(20,60,250,30);
JTextField emailText = new JTextField(30);
emailText.setBounds(90,30,250,30);
Border border = BorderFactory.createLineBorder(Color.BLACK);
emailText.setBorder(border);
JPasswordField passwordText = new JPasswordField(30);
passwordText.setBounds(90, 61, 250, 30);
Border border1 = BorderFactory.createLineBorder(Color.BLACK);
passwordText.setBorder(border);
JButton savePassword = new JButton("Save Password");
savePassword.setBounds(110, 93, 190, 30);
savePassword.addActionListener(new Action());
JLabel savedPasswordHeading = new JLabel("Saved Passwords ");
savedPasswordHeading.setBounds(140, 140, 250, 30);
JLabel savedEmail = new JLabel("Emails :");
savedEmail.setBounds(60, 180, 250, 30);
JLabel savedPasswords = new JLabel("Passwords :");
savedPasswords.setBounds(250, 180, 250, 30);
container.add(savedPasswordHeading);
container.add(savedEmail);
container.add(savedPasswords);
container.add(logo);
container.add(password_label);
container.add(email_label);
container.add(passwordText);
container.add(emailText);
container.add(savePassword);
ourFrame.setVisible(true);
String string = emailText.getText();
char[] passwordGetPassword = passwordText.getPassword();
String fileName = "emailsAndPasswords.txt";
PrintWriter writer = null;
try {
FileWriter w = new FileWriter(fileName);
writer = new PrintWriter(w);
writer.write(string);
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}static class Action implements ActionListener{
private Component parentComponent;
public void actionPerformed (ActionEvent e){
System.out.println("Done!");
JOptionPane.showMessageDialog(parentComponent, "Password Saved!");
}
}
}