Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class RegisterPage extends JFrame implements WindowListener {
private LoginPage loginPage;
JPanel[] panel = new JPanel[5];
JTextField[] textF = new JTextField[4];
JButton[] button = new JButton[2];
JLabel label;
public RegisterPage(LoginPage loginPage) {
this.loginPage = loginPage;
this.setBounds(this.loginPage.getX(), this.loginPage.getY(), this.getWidth(), this.getHeight());
loginPage.setVisible(false);
Container cp = getContentPane();
cp.setLayout(new GridLayout(3, 1));
panel[0] = new JPanel(new GridLayout(2, 2));
panel[1] = new JPanel(new GridLayout(2, 2));
panel[2] = new JPanel(new GridLayout(1, 2));
panel[3] = new JPanel(new FlowLayout());
panel[4] = new JPanel(new FlowLayout());
textF[0] = new JTextField("", 26);
textF[1] = new JTextField("", 26);
textF[2] = new JTextField("", 26);
textF[3] = new JTextField("", 26);
button[0] = new JButton("Done");
button[1] = new JButton("Back");
label = new JLabel("Enter your information correctly.");
DoneAction doneListener = new DoneAction();
button[0].addActionListener(doneListener);
BackAction backListener = new BackAction();
button[1].addActionListener(backListener);
panel[0].add(new JLabel("Username:"));
panel[0].add(textF[0]);
panel[0].add(new JLabel("Password:"));
panel[0].add(textF[1]);
panel[1].add(new JLabel("Name:"));
panel[1].add(textF[2]);
panel[1].add(new JLabel("Surname:"));
panel[1].add(textF[3]);
panel[2].add(panel[3]);
panel[2].add(panel[4]);
panel[3].add(label);
panel[4].add(button[0]);
panel[4].add(button[1]);
cp.add(panel[0]);
cp.add(panel[1]);
cp.add(panel[2]);
this.prepareFrame();
}
public void prepareFrame() {
setVisible(true);
setSize(400, 200);
setResizable(false);
setTitle("Poems From Pens - Register Page");
addWindowListener(this);
}
private class BackAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
loginPage.setBounds(RegisterPage.this.getX(), RegisterPage.this.getY(), loginPage.getWidth(), loginPage.getHeight());
loginPage.setVisible(true);
RegisterPage.this.dispose();
}
}
private class DoneAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
if (!(textF[0].getText().isEmpty() || textF[1].getText().isEmpty() || textF[2].getText().isEmpty() || textF[3].getText().isEmpty())) {
boolean usernameFound = false;
boolean success = false;
BufferedReader reader = null;
String line = null;
try {
String[] user;
reader = new BufferedReader(new FileReader("users.txt"));
while ((line = reader.readLine()) != null) {
user = line.split(",");
if (user.equals(textF[0].getText())) {
usernameFound = true;
break;
}
}
}
catch (IOException e1) {
e1.printStackTrace();
}
finally {
if (reader != null) {
try {
reader.close();
}
catch (IOException e1) {
e1.printStackTrace();
}
}
}
if (usernameFound == false) {
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter("users.txt", true));
writer.write("n" + textF[0].getText() + "," + textF[1].getText() + "," + textF[2].getText() + "," + textF[3].getText());
}
catch (IOException e1) {
e1.printStackTrace();
}
finally {
if (writer != null) {
try {
writer.close();
success = true;
}
catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
if (success == true) {
loginPage.setBounds(RegisterPage.this.getX(), RegisterPage.this.getY(), loginPage.getWidth(), loginPage.getHeight());
loginPage.setVisible(true);
RegisterPage.this.dispose();
}
}
else {
label.setText("Missing information");
}
}
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
![]() |
Notes is a web-based application for online 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 14 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