package LoginSystem;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.reflect.*;
import java.util.List;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.event.DocumentListener;
public class memberFrame implements ActionListener
{
JPanel titlePanel;
JPanel buttonPanel;
JPanel textPanel;
JLabel StringWelcome;
private JButton CompleteButton;
private JButton CancelButton;
JTextField firstName;
JTextField lastName;
JLabel titleLabel = new JLabel("Please fill in your name and desired password below:");
JLabel firstNameLabel = new JLabel("First name:");
JLabel lastNameLabel = new JLabel("Last name:");
JLabel passwordLabel = new JLabel("Password:");
JLabel repeatPasswordLabel = new JLabel("Repeat password:");
JPasswordField password;
JPasswordField repeatPassword;
//**********************************************
//*!CONSTANTS!!CONSTANTS!!CONSTANTS!!CONSTANTS!*
//*!CONSTANTS!!CONSTANTS!!CONSTANTS!!CONSTANTS!*
//**********************************************
private int WindowWidth = 370;
private int WindowHeight = 210;
private String WindowName = "User configuration";
private Members newMember;
private boolean done = false;
private boolean cancel = false;
JFrame frame = new JFrame();
JDialog dialog1 = new JDialog();
JDialog dialog2 = new JDialog();
public JPanel createContentPane()
{
JPanel totalGUI = new JPanel();
totalGUI.setLayout(null);
int titleSize = 320;
titlePanel = new JPanel();
titlePanel.setLayout(null);
titlePanel.setLocation((WindowWidth/2)-titleSize/2,0);
titlePanel.setSize(titleSize,30);
textPanel = new JPanel();
textPanel.setLayout(null);
textPanel.setLocation(20,30);
textPanel.setSize(WindowWidth-40,80);
buttonPanel = new JPanel();
buttonPanel.setLayout(null);
buttonPanel.setLocation(20,WindowHeight-80);
buttonPanel.setSize(WindowWidth-40,40);
titleLabel.setLayout(null);
titleLabel.setLocation(0,0);
titleLabel.setSize(titleSize,20);
titlePanel.add(titleLabel);
firstNameLabel.setLayout(null);
firstNameLabel.setLocation(0,0);
firstNameLabel.setSize(150,20);
textPanel.add(firstNameLabel);
firstName = new JTextField();
firstName.setLayout(null);
firstName.setLocation(0,20);
firstName.setSize(150,20);
textPanel.add(firstName);
lastNameLabel.setLayout(null);
lastNameLabel.setLocation(180,0);
lastNameLabel.setSize(150,20);
textPanel.add(lastNameLabel);
lastName = new JTextField();
lastName.setLayout(null);
lastName.setLocation(180,20);
lastName.setSize(150,20);
textPanel.add(lastName);
passwordLabel.setLayout(null);
passwordLabel.setLocation(0,40);
passwordLabel.setSize(150,20);
textPanel.add(passwordLabel);
password = new JPasswordField();
password.setLayout(null);
password.setLocation(0,60);
password.setSize(150,20);
textPanel.add(password);
repeatPasswordLabel.setLayout(null);
repeatPasswordLabel.setLocation(180,40);
repeatPasswordLabel.setSize(150,20);
textPanel.add(repeatPasswordLabel);
repeatPassword = new JPasswordField();
repeatPassword.setLayout(null);
repeatPassword.setLocation(180,60);
repeatPassword.setSize(150,20);
textPanel.add(repeatPassword);
CompleteButton = new JButton("Complete");
CompleteButton.setLayout(null);
CompleteButton.setLocation(50,0);
CompleteButton.setSize(100,40);
buttonPanel.add(CompleteButton);
CompleteButton.addActionListener(this);
CancelButton = new JButton("Cancel");
CancelButton.setLayout(null);
CancelButton.setLocation(180,0);
CancelButton.setSize(100,40);
buttonPanel.add(CancelButton);
CancelButton.addActionListener(this);
totalGUI.add(titlePanel);
totalGUI.add(textPanel);
totalGUI.add(buttonPanel);
totalGUI.setOpaque(true);
return totalGUI;
}
public Members createGUI()
{
//JFrame.setDefaultLookAndFeelDecorated(true);
//JFrame frame = new JFrame(WindowName);
frame = new JFrame(WindowName);
memberFrame MF = new memberFrame();
dialog1 = new JDialog(frame);
dialog2 = new JDialog(dialog1, "", Dialog.ModalityType.APPLICATION_MODAL);
dialog2.setContentPane(MF.createContentPane());
dialog2.setSize(WindowWidth,WindowHeight);
dialog2.setLocationRelativeTo(null);
dialog2.setResizable(false);
dialog2.setVisible(true);
while(true)
{
if(done == true)
{
return newMember;
//JOptionPane.showMessageDialog(null,"Returning");
// frame.dispose();
}
if(cancel == true)
{
return null;
}
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == CompleteButton)
{
done = true;
String Completefirstname = firstName.getText();
String Completelastname = lastName.getText();
String Completepassword = "Yey";
newMember = new Members(Completefirstname,Completelastname,Completepassword);
frame.dispose();
}else if(e.getSource() == CancelButton)
{
int check = 0;
String[] options = new String[]{"Yes", "No"};
check = JOptionPane.showOptionDialog(null,
"Are you sure you wish to cancel?",
"Attention!",
JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, options,
options[0]);
if(check == 0)
{
dialog2.dispose();
frame.dispose();
JOptionPane.showMessageDialog(null,"dispose");
}
}
}
}