NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package PackagePackage;

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ForgotPasswordPage extends RegulatedJFrame {
private LoginPage loginPage;
JTextField[] textF = new JTextField[3];
JButton[] button = new JButton[2];
JPanel[] panel = new JPanel[4];

public ForgotPasswordPage(LoginPage loginPage) {
this.loginPage = loginPage;
Container cp = getContentPane();
cp.setLayout(new GridLayout(4, 1));
panel[0] = new JPanel(new GridLayout(1, 2));
panel[1] = new JPanel(new GridLayout(1, 2));
panel[2] = new JPanel(new GridLayout(1, 2));
panel[3] = new JPanel(new FlowLayout());
textF[0] = new JTextField("", 26);
textF[1] = new JTextField("", 26);
textF[2] = new JTextField("", 26);
button[0] = new JButton("Done");
DoneAction doneAction = new DoneAction(this.loginPage, this);
button[0].addActionListener(doneAction);
button[1] = new JButton("Back");
BackAction backAction = new BackAction();
button[1].addActionListener(backAction);
panel[0].add(new JLabel("Username:"));
panel[0].add(textF[0]);
panel[1].add(new JLabel("Name:"));
panel[1].add(textF[1]);
panel[2].add(new JLabel("Surname:"));
panel[2].add(textF[2]);
panel[3].add(button[0]);
panel[3].add(button[1]);
cp.add(panel[0]);
cp.add(panel[1]);
cp.add(panel[2]);
cp.add(panel[3]);
this.prepareFrame();
}

protected void prepareFrame() {
super.prepareFrame("Poems From Pens - Forgot Password Page", 300, 160);
this.setBounds(this.loginPage.getX(), this.loginPage.getY(), this.getWidth(), this.getHeight());
}

private class BackAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
loginPage.setBounds(ForgotPasswordPage.this.getX(), ForgotPasswordPage.this.getY(), loginPage.getWidth(),
loginPage.getHeight());
loginPage.setVisible(true);
ForgotPasswordPage.this.dispose();
}
}

private class DoneAction implements ActionListener {
private LoginPage loginPage;
private ForgotPasswordPage FPP;

public DoneAction(LoginPage loginPage, ForgotPasswordPage FPP) {
this.loginPage = loginPage;
this.FPP = FPP;
}

@Override
public void actionPerformed(ActionEvent e) {
if (!(textF[0].getText().isEmpty() || textF[1].getText().isEmpty() || textF[2].getText().isEmpty())) {
BufferedReader reader = null;
String line = null;
String forgottenPassword = null;
try {
String[] user;
reader = new BufferedReader(new FileReader("users.txt"));
while ((line = reader.readLine()) != null) {
user = line.split(",");
if (textF[0].getText().equals(user[0]) && textF[1].getText().equals(user[2])
&& textF[2].getText().equals(user[3])) {
forgottenPassword = user[1];
break;
}
}
if (forgottenPassword != null) {
new ForgottenPasswordFrame(forgottenPassword, loginPage, FPP);
} else {
JOptionPane.showMessageDialog(null, "Invalid username, name, or surname.", "Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (IOException e1) {
e1.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
} else {
JOptionPane.showMessageDialog(null, "Please fill in all fields.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}

private class ForgottenPasswordFrame extends RegulatedJFrame {
private LoginPage loginPage;
private ForgotPasswordPage FPP;
JButton button;
JPanel[] panel = new JPanel[2];

public ForgottenPasswordFrame(String password, LoginPage loginPage, ForgotPasswordPage FPP) {
this.loginPage = loginPage;
this.FPP = FPP;
Container cp = getContentPane();
cp.setLayout(new GridLayout(2, 1));
panel[0] = new JPanel(new FlowLayout());
panel[1] = new JPanel(new FlowLayout());
button = new JButton("Got it");
FPPAction FPPaction = new FPPAction(loginPage, FPP, this);
button.addActionListener(FPPaction);
cp.add(panel[0]);
cp.add(panel[1]);
panel[0].add(new JLabel("Your password is: " + password));
panel[1].add(button);
this.prepareFrame();
}

private class FPPAction implements ActionListener {
private LoginPage loginPage;
private ForgottenPasswordFrame forgottenPP;

public FPPAction(LoginPage loginPage, ForgotPasswordPage FPP, ForgottenPasswordFrame forgottenPP) {
this.loginPage = loginPage;
this.forgottenPP = forgottenPP;
}

@Override
public void actionPerformed(ActionEvent e) {
this.loginPage.setVisible(true);
this.forgottenPP.dispose();
}
}

protected void prepareFrame() {
super.prepareFrame("Notification", 300, 160);
this.setBounds(this.FPP.getX(), this.FPP.getY(), this.getWidth(), this.getHeight());
}

@Override
public void windowOpened(WindowEvent e) {
this.FPP.dispose();
}

@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}

@Override
public void windowClosed(WindowEvent e) {
loginPage.setBounds(this.getX(), this.getY(), this.loginPage.getWidth(), this.loginPage.getHeight());
}

@Override
public void windowIconified(WindowEvent e) {
}

@Override
public void windowDeiconified(WindowEvent e) {
}

@Override
public void windowActivated(WindowEvent e) {
}

@Override
public void windowDeactivated(WindowEvent e) {
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.