Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (cont == true) {
- answer = login.getEntered();
- if (answer.equals("Y")) {
- cont = false;
- } else {
- cont = true;
- }
- }
- package com.company;
- /*
- */
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.IOException;
- public class logInScreen extends JFrame {
- private static String usernameInput = "";
- private static String passwordInput = "";
- private static JPanel panel = new JPanel();
- private static String entered = "";
- public logInScreen() {
- setEntered("empty");
- this.setTitle("Log In");
- this.setSize(400, 400);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- usernameArea();
- passwordArea();
- button("Log In");
- createNewAccount();
- this.add(panel);
- this.setVisible(true);
- }
- public static void usernameArea() {
- JTextArea username = new JTextArea(1, 15);
- username.setText("");
- username.setLineWrap(true);
- JScrollPane pane = new JScrollPane(username, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- panel.add(pane);
- }
- public static void passwordArea() {
- JTextArea password = new JTextArea(1, 15);
- password.setText("");
- password.setLineWrap(true);
- JScrollPane pane2 = new JScrollPane(password, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- panel.add(pane2);
- }
- public void button(String text) {
- JButton btn = new JButton();
- btn.setText(text);
- btn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setEntered("Y");
- System.out.println(getEntered());
- }
- });
- panel.add(btn);
- }
- public static void createNewAccount(){
- JTextArea label = new JTextArea(1,30);
- label.setLineWrap(true);
- label.setEditable(false);
- label.setText(" New User?");
- panel.add(label);
- JButton newAccount = new JButton();
- newAccount.setText("Create New Account!");
- newAccount.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- createLoginScreen newAccount = new createLoginScreen();
- }
- });
- panel.add(newAccount);
- }
- public void setEntered(String val){
- entered = val;
- }
- public String getEntered() {
- return entered;
- }
- public String getUsernameInput() {
- return usernameInput;
- }
- public String getPasswordInput() {
- return passwordInput;
- }
- public void close() {
- this.setVisible(false);
- this.dispose();
- }
- }
Add Comment
Please, Sign In to add comment