Guest User

Untitled

a guest
Nov 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. while (cont == true) {
  2.  
  3. answer = login.getEntered();
  4.  
  5. if (answer.equals("Y")) {
  6.  
  7. cont = false;
  8.  
  9. } else {
  10.  
  11. cont = true;
  12.  
  13. }
  14. }
  15.  
  16. package com.company;
  17.  
  18. /*
  19.  
  20.  
  21.  
  22. */
  23.  
  24. import javax.swing.*;
  25. import java.awt.*;
  26. import java.awt.event.ActionEvent;
  27. import java.awt.event.ActionListener;
  28. import java.io.IOException;
  29.  
  30. public class logInScreen extends JFrame {
  31.  
  32. private static String usernameInput = "";
  33. private static String passwordInput = "";
  34.  
  35. private static JPanel panel = new JPanel();
  36.  
  37. private static String entered = "";
  38.  
  39. public logInScreen() {
  40.  
  41.  
  42. setEntered("empty");
  43.  
  44. this.setTitle("Log In");
  45. this.setSize(400, 400);
  46. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  47.  
  48. usernameArea();
  49. passwordArea();
  50. button("Log In");
  51. createNewAccount();
  52. this.add(panel);
  53.  
  54. this.setVisible(true);
  55.  
  56. }
  57.  
  58. public static void usernameArea() {
  59.  
  60. JTextArea username = new JTextArea(1, 15);
  61. username.setText("");
  62. username.setLineWrap(true);
  63. JScrollPane pane = new JScrollPane(username, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  64. panel.add(pane);
  65.  
  66. }
  67.  
  68. public static void passwordArea() {
  69. JTextArea password = new JTextArea(1, 15);
  70. password.setText("");
  71. password.setLineWrap(true);
  72. JScrollPane pane2 = new JScrollPane(password, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  73. panel.add(pane2);
  74.  
  75.  
  76. }
  77.  
  78.  
  79. public void button(String text) {
  80.  
  81. JButton btn = new JButton();
  82. btn.setText(text);
  83.  
  84. btn.addActionListener(new ActionListener() {
  85. @Override
  86. public void actionPerformed(ActionEvent e) {
  87.  
  88. setEntered("Y");
  89. System.out.println(getEntered());
  90.  
  91. }
  92. });
  93.  
  94. panel.add(btn);
  95.  
  96. }
  97.  
  98. public static void createNewAccount(){
  99.  
  100. JTextArea label = new JTextArea(1,30);
  101. label.setLineWrap(true);
  102. label.setEditable(false);
  103. label.setText(" New User?");
  104.  
  105. panel.add(label);
  106.  
  107. JButton newAccount = new JButton();
  108. newAccount.setText("Create New Account!");
  109.  
  110. newAccount.addActionListener(new ActionListener() {
  111. @Override
  112. public void actionPerformed(ActionEvent e) {
  113.  
  114. createLoginScreen newAccount = new createLoginScreen();
  115.  
  116. }
  117. });
  118.  
  119. panel.add(newAccount);
  120.  
  121. }
  122.  
  123. public void setEntered(String val){
  124.  
  125. entered = val;
  126.  
  127. }
  128.  
  129. public String getEntered() {
  130.  
  131. return entered;
  132.  
  133. }
  134.  
  135. public String getUsernameInput() {
  136.  
  137. return usernameInput;
  138.  
  139. }
  140.  
  141. public String getPasswordInput() {
  142.  
  143. return passwordInput;
  144.  
  145. }
  146.  
  147. public void close() {
  148.  
  149. this.setVisible(false);
  150. this.dispose();
  151.  
  152. }
  153.  
  154. }
Add Comment
Please, Sign In to add comment