Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import javax.swing.JLabel;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JPasswordField;
- public class MyWinBuild extends JFrame {
- private JPanel contentPane;
- private JTextField firstName;
- private JLabel firstNameLabel;
- private JTextField lastName;
- private JLabel lastNameLabel;
- private JTextField userName;
- private JPasswordField passwordField;
- public static MyWinBuild createAccountFrame = new MyWinBuild();
- public static void main(String[] args)
- {
- createAccountFrame.setVisible(true);
- }
- //Create the frame.
- public MyWinBuild() {
- setType(Type.UTILITY);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 450, 300);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- //This is the info label.
- JLabel InforLabel = new JLabel("Fill in the information below");
- InforLabel.setBounds(130, 13, 169, 16);
- contentPane.add(InforLabel);
- /*
- * FirstName
- */
- //First Name label
- firstNameLabel = new JLabel("First Name");
- firstNameLabel.setBounds(85, 57, 68, 16);
- contentPane.add(firstNameLabel);
- //First Name input
- firstName = new JTextField();
- firstName.setBounds(61, 86, 116, 22);
- contentPane.add(firstName);
- firstName.setColumns(10);
- /*
- * LastName
- */
- //Last Name label
- lastNameLabel = new JLabel("Last Name");
- lastNameLabel.setBounds(266, 57, 68, 16);
- contentPane.add(lastNameLabel);
- //Last Name Input
- lastName = new JTextField();
- lastName.setBounds(233, 86, 133, 22);
- contentPane.add(lastName);
- lastName.setColumns(10);
- /*
- * UserName
- */
- //User Name label
- JLabel userNameLabel = new JLabel("User Name");
- userNameLabel.setBounds(85, 120, 68, 16);
- contentPane.add(userNameLabel);
- //User Name input
- userName = new JTextField();
- userName.setBounds(61, 149, 116, 22);
- contentPane.add(userName);
- userName.setColumns(10);
- /*
- * Password
- */
- //Password label
- JLabel passwordLabel = new JLabel("Password");
- passwordLabel.setBounds(266, 121, 68, 16);
- contentPane.add(passwordLabel);
- //Password input
- passwordField = new JPasswordField();
- passwordField.setBounds(233, 149, 133, 22);
- contentPane.add(passwordField);
- /*
- * Button
- */
- JButton applyBtn = new JButton("Apply");
- applyBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- String fn = firstName.getText(); //Set a new variable "fn" to the textinput.
- String ln = lastName.getText(); //Set a new variable "ln" to the textinput.
- String username = userName.getText(); //Set a new variable "username" to the textinput.
- char[] password = passwordField.getPassword(); //Creates a list "password[]" to store the Password.
- //Creates a new Database.
- DataBase db = new DataBase();
- //Set the name in the DataBase class.
- db.setFirstname(fn);
- db.setLastname(ln);
- db.setUsername(username);
- db.setPassword(password);
- db.save();
- System.out.println(db.getFirstname()); //For Testing.
- System.out.println(db.getLastname());
- System.out.println(db.getUsername());
- System.out.println(db.getPassword());
- //Create a new WinBuild for the LoginScreen.
- LoginMyWinBuild newWindow = new LoginMyWinBuild();
- //Set the current window to visibility to false.
- createAccountFrame.setVisible(false);
- //And then set the New login Window to visibility true.
- newWindow.setVisible(true);
- }
- });
- applyBtn.setBounds(323, 215, 97, 25);
- contentPane.add(applyBtn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement