From 56a2b9d4224c7f8e9a427f13d0ed8f5640e6d9cd Mon Sep 17 00:00:00 2001 From: 50582 <505822174@qq.com> Date: Wed, 4 Dec 2019 19:37:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=91=A0=E4=BC=98=E5=8C=96=E4=BA=86?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E3=80=81=E5=AF=86=E7=A0=81=E6=9C=AA=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=97=B6=E4=B8=8D=E8=83=BD=E7=82=B9=E5=87=BBLogin?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E4=B8=80=E4=BA=9B=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E3=80=82=20=E2=91=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E2=80=9C=E8=AE=B0=E4=BD=8F=E8=B4=A6=E5=8F=B7=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E2=80=9D=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=9C=A8=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=BA=86=E2=80=9CRemember=20my=20password=E2=80=9D?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=A1=86=20=E6=97=B6=EF=BC=8C=E4=B8=8B?= =?UTF-8?q?=E6=AC=A1=E7=99=BB=E5=BD=95=E6=97=B6=E8=B4=A6=E5=8F=B7=E5=92=8C?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=A1=86=E4=BC=9A=E8=87=AA=E5=8A=A8=E5=A1=AB?= =?UTF-8?q?=E5=85=A5=E4=B8=8A=E6=AC=A1=E7=99=BB=E5=BD=95=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E5=AF=86=E7=A0=81=E3=80=82=EF=BC=88=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=96=87=E4=BB=B6=E6=9C=AA=E5=81=9A=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=EF=BC=89=20=E2=91=A2=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=B8=80=E4=BA=9BBUG?= =?UTF-8?q?=E3=80=82=20=E2=91=A3=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=BD=AE=E6=94=BEtxt=E6=96=87=E6=9C=AC=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/imgzip/CreateAccount.java | 61 ---- src/imgzip/CreateAccountController.java | 286 ------------------- src/imgzip/CreateSuccessfullyController.java | 39 --- src/imgzip/DataBaseController.java | 96 ------- src/imgzip/Login.java | 156 ---------- src/imgzip/LoginController.java | 189 ------------ src/imgzip/WrongPassword.java | 30 -- src/imgzip/WrongPasswordController.java | 61 ---- 8 files changed, 918 deletions(-) delete mode 100644 src/imgzip/CreateAccount.java delete mode 100644 src/imgzip/CreateAccountController.java delete mode 100644 src/imgzip/CreateSuccessfullyController.java delete mode 100644 src/imgzip/DataBaseController.java delete mode 100644 src/imgzip/Login.java delete mode 100644 src/imgzip/LoginController.java delete mode 100644 src/imgzip/WrongPassword.java delete mode 100644 src/imgzip/WrongPasswordController.java diff --git a/src/imgzip/CreateAccount.java b/src/imgzip/CreateAccount.java deleted file mode 100644 index fc8a0df..0000000 --- a/src/imgzip/CreateAccount.java +++ /dev/null @@ -1,61 +0,0 @@ -package imgzip; - -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.stage.Stage; - -import javafx.scene.control.Label; - -/** - @Author: 肖尧 - @Date: 2019.12.4 - */ -public class CreateAccount { - public CreateAccount(){ - try { - Parent root = FXMLLoader.load(getClass().getResource("/fxml/CreateAccount.fxml")); - - Label already = (Label)root.lookup("#Al"); - already.setVisible(false); - - Label already2 = (Label)root.lookup("#Al2"); - already2.setVisible(false); - - Button createAccount = (Button)root.lookup("#createAccount"); - createAccount.setDisable(true); - - Stage primaryStage = new Stage(); - primaryStage.setTitle("Create an Account"); - primaryStage.setScene(new Scene(root, 600.0000999999975, 633)); - primaryStage.show(); - - }catch (Exception e){ - e.printStackTrace(); - } - - } -} - -class CreateSuccessfully{ - - public CreateSuccessfully(){ - - try { - Parent root = FXMLLoader.load(getClass().getResource("/fxml/CreateSuccessfully.fxml")); - - Stage primaryStage = new Stage(); - primaryStage.setTitle("Create an Account Successfully!"); - primaryStage.setScene(new Scene(root, 638, 406)); - primaryStage.show(); - - }catch (Exception e){ - e.printStackTrace(); - } - - - } - -} - diff --git a/src/imgzip/CreateAccountController.java b/src/imgzip/CreateAccountController.java deleted file mode 100644 index 6a2c88b..0000000 --- a/src/imgzip/CreateAccountController.java +++ /dev/null @@ -1,286 +0,0 @@ -package imgzip; -import javafx.application.Platform; -import javafx.fxml.FXML; -import javafx.scene.control.*; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import javafx.scene.control.Alert; -import javafx.scene.web.WebEngine; -import javafx.scene.web.WebView; -import javafx.stage.Stage; - -import java.awt.*; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.sql.ResultSet; -import java.sql.SQLException; - -/** - @Author: 肖尧 - @Date: 2019.12.4 - */ -public class CreateAccountController { - - @FXML - private TextField userName; - - @FXML - private TextField passWord; - - @FXML - private TextField email; - - @FXML - private TextField telephone; - - @FXML - private CheckBox agree; - - @FXML - private Button createAccount; - - @FXML - private Hyperlink privacy; - - @FXML - private Label already; - - @FXML - private Label already2; - - @FXML - private Hyperlink signIn; - - - /** - * SignIn点击后,返回登录页面并关闭注册页面 - */ - public void backToLogin() { - Stage stage = (Stage) signIn.getScene().getWindow(); - new Loginbeginner(); - stage.close(); - - } - - /** - * 检查账号是否存在,如果存在则无法点击注册按钮,且会提醒用户。 - */ - boolean judgeAccountExists = false; - public void checkAccountExistence() { - DataBaseController createAccountInstruction = new DataBaseController(); - ResultSet rs = null; - ResultSet rs2 = null; - - try { - /** - 第一步,检查数据库中是否有该账号存在 - */ - String currentInstruction = "SELECT pwd FROM login WHERE userName=" + "'" + userName.getText().trim() + "'"; - rs = createAccountInstruction.queryExcecute(currentInstruction); - - /** - * 第二步: - * ①如果账号为空,则无法点击注册按钮。 - * ②如果账号存在,无法点击。 - * ③如果账号不存在,邮箱存在,无法点击。 - * ④如果账号邮箱都不存在,但是未同意服务条款,无法点击。 - * ⑤如果账号邮箱都不存在,且同意了服务条款,才可被点击。 - */ - - if("".equals(userName.getText())){ - createAccount.setDisable(true); - - }else { - if (rs.next()) { - judgeAccountExists = true; - already.setVisible(true); - - if(!createAccount.isDisable()){ - createAccount.setDisable(true); - - } - }else{ - judgeAccountExists = false; - already.setVisible(false); - - if(!judgeEmialexist && agree.isSelected()){ - createAccount.setDisable(false); - - } - - } - - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - createAccountInstruction.close(); - } - - } - - /** - * 检查邮箱是否存在,如果存在则无法点击注册按钮,且会提醒用户。 - */ - - boolean judgeEmialexist = false; - public void checkEmailExistence() { - - DataBaseController createAccountInstruction = new DataBaseController(); - ResultSet rs = null; - ResultSet rs2 = null; - - try { - String currentInstruction2 = "SELECT pwd FROM login WHERE email=" + "'" + email.getText().trim() + "'"; - rs2 = createAccountInstruction.queryExcecute(currentInstruction2); - - /** - * 第二步: - * ①如果账号为空,则无法点击注册按钮。 - * ②如果账号存在,无法点击。 - * ③如果账号不存在,邮箱存在,无法点击。 - * ④如果账号邮箱都不存在,但是未同意服务条款,无法点击。 - * ⑤如果账号邮箱都不存在,且同意了服务条款,才可被点击。 - */ - - if ("".equals(email.getText())){ - createAccount.setDisable(true); - - }else { - if (rs2.next()) { - judgeEmialexist = true; - already2.setVisible(true); - - if(!createAccount.isDisable()){ - createAccount.setDisable(true); - - } - }else{ - judgeEmialexist = false; - already2.setVisible(false); - - if(!judgeAccountExists && agree.isSelected()){ - createAccount.setDisable(false); - - } - - } - - } - } catch (Exception e) { - e.printStackTrace(); - - } finally { - createAccountInstruction.close(); - - } - - } - - /** - * CreateAccount点击后,将账号插入数据库中 - */ - public void createAccount() { - DataBaseController createAccountInstruction = new DataBaseController(); - ResultSet rs = null; - - try { - /** - 向数据库中插入数据 - */ - String currentInstruction = "INSERT INTO login (userName,pwd,email,tel) values(" + "'"+userName.getText().trim()+ "'" + "," + "'"+ passWord.getText().trim()+ "'" + "," + "'"+ email.getText().trim() + "'"+ "," + "'"+telephone.getText().trim()+ "'"+")" ; - createAccountInstruction.queryUpdate(currentInstruction); - - /** - 检查数据库中是否成功插入数据 - */ - String currentInstruction2 = "SELECT pwd FROM login WHERE userName=" + "'" + userName.getText().trim() + "'"; - rs = createAccountInstruction.queryExcecute(currentInstruction2); - - if(rs.next()){ - Stage stage = (Stage) signIn.getScene().getWindow(); - new CreateSuccessfully(); - stage.close(); - - }else{ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("SORRY!"); - alert.setHeaderText("Something's wrong!"); - alert.setContentText("The Account is not created"); - alert.showAndWait(); - - } - - } catch (Exception e) { - e.printStackTrace(); - System.out.println("456"); - - } finally { - createAccountInstruction.close(); - - } - - } - - /** - * 检查是否点击了同意privacy协议,如果不同意,则无法点击 createaccount 按钮。 - */ - public void checkIfSelectedPrivacy(){ - if(!judgeAccountExists && !judgeEmialexist && createAccount.isDisable()){ - createAccount.setDisable(false); - - } - - boolean userNmae = "".equals(userName.getText()); - boolean emial = "".equals(email.getText()); - - if(!agree.isSelected() || userNmae || emial ){ - createAccount.setDisable(true); - - } - } - - /** - * 点击Privacy 的 hyperlink后,跳出网页进入隐私条例说明。 - */ - public void openPrivacy(){ - - try{ - try { - Desktop.getDesktop().browse(new URI("https://www.epicgames.com/site/en-US/privacypolicy?lang=en-US&sessionInvalidated=true")); - - }catch (IOException e){ - System.out.println("123"); - - } - }catch (URISyntaxException e){ - System.out.println("456"); - - } - } - - - /** - * 点击Service 的 hyperlink后,跳出网页进入服务说明。 - */ - public void openService(){ - - try{ - try { - Desktop.getDesktop().browse(new URI("https://www.epicgames.com/site/en-US/tos?lang=en-US")); - - }catch (IOException e){ - System.out.println("123"); - - } - }catch (URISyntaxException e){ - System.out.println("456"); - - } - } - -} - - diff --git a/src/imgzip/CreateSuccessfullyController.java b/src/imgzip/CreateSuccessfullyController.java deleted file mode 100644 index 2e59f53..0000000 --- a/src/imgzip/CreateSuccessfullyController.java +++ /dev/null @@ -1,39 +0,0 @@ -package imgzip; - -import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.stage.Stage; -/** - @Author: 肖尧 - @Date: 2019.11.24 - */ - -public class CreateSuccessfullyController{ - @FXML - private Button signUp; - - @FXML - private Button signIn; - - - /** - * 点击后sign up 后回到登录页面。 - */ - public void backToLogin() { - Stage stage = (Stage) signUp.getScene().getWindow(); - new Loginbeginner(); - stage.close(); - - } - - - /** - * 点击后sign in again 后继续注册。 - */ - public void backToSignIn() { - Stage stage = (Stage) signIn.getScene().getWindow(); - new CreateAccount(); - stage.close(); - - } -} diff --git a/src/imgzip/DataBaseController.java b/src/imgzip/DataBaseController.java deleted file mode 100644 index 2779ab3..0000000 --- a/src/imgzip/DataBaseController.java +++ /dev/null @@ -1,96 +0,0 @@ -package imgzip; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; - -public class DataBaseController { - - PreparedStatement ps = null; - Connection ct = null; - ResultSet rs = null; - String url = "jdbc:mysql://120.78.208.4/javaProgrem";//待定调整 - String user = "javaP" ;//待定调整 - String password = "1801090042"; //待定调整 - String driver = "com.mysql.cj.jdbc.Driver"; - - - //关闭资源 - public void close(){ - - try{ - - if(rs != null) { - rs.close(); - } - if (ps != null) { - ps.close(); - } - if (ct != null) { - ct.close(); - - } - - }catch (Exception ex){ - ex.printStackTrace(); - } - } - - public void jdbcConnection(){ - try { - - Class.forName(driver).newInstance(); - ct = DriverManager.getConnection(url,user,password); - System.out.println("连接成功"); - }catch (Exception ex){ - System.out.println("连接失败"); - ex.printStackTrace(); - - } - - } - - - //执行某个查询方法 - public ResultSet queryExcecute(String sql){ - - try { - - Class.forName(driver); - - ct = DriverManager.getConnection(url,user,password); - - ps = ct.prepareStatement(sql); - - rs = ps.executeQuery(); - - }catch (Exception ex){ - ex.printStackTrace(); - - } - - return rs; - } - - - public void queryUpdate(String sql){ - try { - - Class.forName(driver); - - ct = DriverManager.getConnection(url,user,password); - - ps = ct.prepareStatement(sql); - - ps.executeUpdate(); - - }catch (Exception ex){ - ex.printStackTrace(); - - } - - } - - -} diff --git a/src/imgzip/Login.java b/src/imgzip/Login.java deleted file mode 100644 index 9f92445..0000000 --- a/src/imgzip/Login.java +++ /dev/null @@ -1,156 +0,0 @@ -package imgzip; - -import javafx.application.Application; -import javafx.application.Platform; -import javafx.beans.InvalidationListener; -import javafx.beans.Observable; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.TextField; -import javafx.scene.control.PasswordField; -import javafx.scene.layout.BorderPane; -import javafx.stage.Stage; - -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; - -/** - @Author: 肖尧 - @Date: 2019.12.4 - */ -public class Login extends Application { - - @Override - public void start(Stage primaryStage) throws Exception{ - - try { - - Parent root = FXMLLoader.load(getClass().getResource("/fxml/Login.fxml")); - - TextField account = (TextField)root.lookup("#Account"); - PasswordField password = (PasswordField)root.lookup("#password"); - CheckBox remember = (CheckBox)root.lookup("#remember"); - Button logIn = (Button)root.lookup("#Login"); - - - /** - 在页面开启之前检查上一次登录时是否记住了密码, - 如果上一次登录点击了记住密码,则在本次打开时会将账号和密码写入 - */ - try { - - FileReader fr = new FileReader("src/txtFile/RememberAccount&Password.txt"); - BufferedReader br = new BufferedReader(fr); - - String line = ""; - line = br.readLine(); - - - String[] judge = line.split("\\|"); - String truejudge = "true"; - int accountIndex = 0; - int passwordIndex = 1; - int judgeIndex = 2; - - if(judge[judgeIndex].equals(truejudge) ){ - account.setText(judge[accountIndex]); - password.appendText(judge[passwordIndex]); - - remember.setSelected(true); - logIn.setDisable(false); - - } - - br.close(); - fr.close(); - - }catch (Exception e){ - e.printStackTrace(); - - } - - primaryStage.setTitle("XXX login"); - primaryStage.setScene(new Scene(root, 638, 400)); - primaryStage.show(); - - }catch (Exception e){ - e.printStackTrace(); - - } - - } - - public static void main(String[] args) { - launch(args); - } - -} - - -class Loginbeginner{ - public Loginbeginner(){ - try { - Stage primaryStage = new Stage(); - Parent root = FXMLLoader.load(getClass().getResource("/fxml/Login.fxml")); - - TextField account = (TextField)root.lookup("#Account"); - PasswordField password = (PasswordField)root.lookup("#password"); - CheckBox remember = (CheckBox)root.lookup("#remember"); - Button logIn = (Button)root.lookup("#Login"); - - - /** - 在页面开启之前检查上一次登录时是否记住了密码, - 如果上一次登录点击了记住密码,则在本次打开时会将账号和密码写入 - */ - try { - - FileReader fr = new FileReader("src/txtFile/RememberAccount&Password.txt"); - BufferedReader br = new BufferedReader(fr); - - String line = ""; - line = br.readLine(); - - - String[] judge = line.split("\\|"); - String truejudge = "true"; - int accountIndex = 0; - int passwordIndex = 1; - int judgeIndex = 2; - - if(judge[judgeIndex].equals(truejudge) ){ - account.setText(judge[accountIndex]); - password.appendText(judge[passwordIndex]); - - remember.setSelected(true); - logIn.setDisable(false); - - } - - br.close(); - fr.close(); - - }catch (Exception e){ - e.printStackTrace(); - - } - - primaryStage.setTitle("XXX login"); - primaryStage.setScene(new Scene(root, 638, 400)); - primaryStage.show(); - - }catch (Exception e){ - e.printStackTrace(); - - } - - } - -} \ No newline at end of file diff --git a/src/imgzip/LoginController.java b/src/imgzip/LoginController.java deleted file mode 100644 index 6c47f3d..0000000 --- a/src/imgzip/LoginController.java +++ /dev/null @@ -1,189 +0,0 @@ -package imgzip; - -import javafx.application.Platform; -import javafx.fxml.FXML; -import javafx.scene.control.Alert; -import javafx.scene.control.Button; -import javafx.scene.control.TextField; -import javafx.scene.control.CheckBox; -import javafx.stage.Stage; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; - -import java.sql.SQLException; -import java.sql.Statement; - - -/** - @Author:肖尧 - @Date:2019.11.24 - */ -public class LoginController { - - - @FXML - private TextField account; - - @FXML - private TextField password; - - @FXML - private CheckBox remember; - - @FXML - private Button login; - - @FXML - private Button cancel; - - @FXML - private Button cantSign; - - @FXML - private Button createAccount; - - - - /** - 检查用户是否输入了用户名和密码, - 如果只输入了用户名,或只输入了密码,或两者都没输入,则按钮LOGIN无法被点击, - 当用户名与密码同时被输入时,按钮LOGIN才能被点击。 - */ - public void check(){ - - String stringAccount = account.getText(); - String stringPassword = password.getText(); - String ifEmpty = ""; - - if ( (stringAccount.equals(ifEmpty) || stringPassword.equals(ifEmpty))){ - login.setDisable(true); - - }else if ((!stringAccount.equals(ifEmpty) && !stringPassword.equals(ifEmpty))){ - login.setDisable(false); - } - } - - - /** - 检查是否已经连上数据库 - */ - - public void dataBaseConnectionCheck(){ - DataBaseController loginInstruction = new DataBaseController(); - try { - loginInstruction.jdbcConnection(); - }catch (Exception ex){ - ex.printStackTrace(); - loginInstruction.close(); - } - } - - /** - 用户点击此按钮时, - ①:如果账号不存在或账号存在但是密码错误,则进入密码错误页面。 - ②:如果账号存在且密码正确,则进入主页面(尚未完成)。 - ③:如果勾选了记住账号和密码,则在下一次打开页面时会记住上一次的密码。 - */ - - public void login(){ - - DataBaseController loginInstruction = new DataBaseController(); - ResultSet rs = null; - try{ - - String currentInstruction = "SELECT pwd FROM login WHERE userName=" + "'" + account.getText().trim()+ "'"; - rs = loginInstruction.queryExcecute(currentInstruction); - - - if (rs.next()) { - String rightPassword = rs.getString(1); - if (rightPassword.equals(password.getText())){ - - remember(); - //登入主页面,待定 - System.out.println("登录1"); - - }else{ - new WrongPassword(); - Stage stage = (Stage)createAccount.getScene().getWindow(); - stage.close(); - } - - }else { - new WrongPassword(); - Stage stage = (Stage)createAccount.getScene().getWindow(); - stage.close(); - - } - - }catch (SQLException e){ - e.printStackTrace(); - - }finally { - loginInstruction.close(); - } - } - - - /** - 设置cancel按钮,可以直接点击这里完成窗口的关闭。 - */ - public void cancel(){ - - Stage stage = (Stage)cancel.getScene().getWindow(); - stage.close(); - } - - - - /** - 设置记住账号密码按钮的方法。 - */ - - public void remember(){ - boolean ifclick = remember.isSelected(); - String judgeIfclick = ""; - - if(ifclick){ - judgeIfclick = "true"; - }else { - judgeIfclick = "false"; - } - - try { - FileWriter fw = new FileWriter("src/txtFile/RememberAccount&Password.txt"); - BufferedWriter fis = new BufferedWriter(fw); - - fis.write(account.getText() +"|"+ password.getText() + "|" + judgeIfclick ); - fis.newLine(); - - fis.close(); - fw.close(); - - }catch (Exception e){ - e.printStackTrace(); - } - } - - - /** - 点击注册页面的方法,用户点击以后直接进入注册页面。 - */ - public void createAccount(){ - new CreateAccount(); - Stage stage = (Stage)createAccount.getScene().getWindow(); - stage.close(); - } - - - -} - diff --git a/src/imgzip/WrongPassword.java b/src/imgzip/WrongPassword.java deleted file mode 100644 index 39416f3..0000000 --- a/src/imgzip/WrongPassword.java +++ /dev/null @@ -1,30 +0,0 @@ -package imgzip; - -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - - -/** - @Author: 肖尧 - @Date: 2019.11.24 - */ - -public class WrongPassword { - public WrongPassword(){ - - try { - - Parent root = FXMLLoader.load(getClass().getResource("/fxml/WrongPassword.fxml")); - Stage primaryStage = new Stage(); - primaryStage.setTitle("Password is wrong!"); - primaryStage.setScene(new Scene(root, 638.0, 400)); - primaryStage.show(); - - }catch (Exception e){ - e.printStackTrace(); - } - - } -} diff --git a/src/imgzip/WrongPasswordController.java b/src/imgzip/WrongPasswordController.java deleted file mode 100644 index b1793a3..0000000 --- a/src/imgzip/WrongPasswordController.java +++ /dev/null @@ -1,61 +0,0 @@ -package imgzip; -import javafx.application.Platform; -import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.stage.Stage; -import sun.rmi.runtime.Log; - -import java.sql.ResultSet; -import java.sql.SQLException; - - -/** - @Author:肖尧 - @Date:2019.11.24 - */ -public class WrongPasswordController { - - @FXML - private Button createAccount; - - @FXML - private Button findPassword; - - @FXML - private Button back; - - - /** - 设置createAccount事件, - 当用户点击该按钮的时候,跳转至用户注册页面 - */ - - public void createAccount(){ - new CreateAccount(); - Stage stage = (Stage)back.getScene().getWindow(); - stage.close(); - } - - - /** - 设置findPassword事件, - 当用户点击该按钮的时候,跳转至用户找回密码页面 - */ - public void findPassword(){ - - } - - - /** - 设置back事件, - 当用户点击该按钮的时候,跳转至登录界面 - */ - public void back(){ - - Stage stage = (Stage)back.getScene().getWindow(); - stage.close(); - new Loginbeginner(); - } - - -} -- Gitee From 2f15e6bf2088ffc3b80aa5a28dbee26d6299496a Mon Sep 17 00:00:00 2001 From: 50582 <505822174@qq.com> Date: Wed, 11 Dec 2019 20:44:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0jdbc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JavaProgrem.iml | 2 +- src/fxml/ChangePassword.fxml | 94 +++++++++++++ src/fxml/ChangePasswordSuccessfully.fxml | 54 ++++++++ src/fxml/CreateAccount.fxml | 16 ++- src/fxml/CreateSuccessfully.fxml | 24 ++-- src/fxml/FindPassword.fxml | 98 ++++++++++++++ src/fxml/Login.fxml | 6 +- src/fxml/WrongPassword.fxml | 2 +- src/imgzip/Login_SignIn/ChangePassword.java | 44 ++++++ .../ChangePasswordController.java | 85 ++++++++++++ .../ChangePasswordSuccessfullyController.java | 4 + src/imgzip/Login_SignIn/CreateAccount.java | 2 - .../Login_SignIn/CreateAccountController.java | 1 - src/imgzip/Login_SignIn/FindPassword.java | 30 ++++ .../Login_SignIn/FindPasswordController.java | 128 ++++++++++++++++++ .../Login_SignIn/GlobalStringManager.java | 13 ++ src/imgzip/Login_SignIn/LoginController.java | 11 +- src/imgzip/Login_SignIn/WrongPassword.java | 7 + .../driver/mysql-connector-java-8.0.16.jar | Bin 0 -> 2293144 bytes src/res/icon/Happyface.png | Bin 0 -> 26557 bytes src/res/icon/sad face.png | Bin 0 -> 38498 bytes src/res/icon/think face.jpg | Bin 0 -> 42740 bytes src/res/icon/think face.png | Bin 0 -> 53759 bytes 23 files changed, 592 insertions(+), 29 deletions(-) create mode 100644 src/fxml/ChangePassword.fxml create mode 100644 src/fxml/ChangePasswordSuccessfully.fxml create mode 100644 src/fxml/FindPassword.fxml create mode 100644 src/imgzip/Login_SignIn/ChangePassword.java create mode 100644 src/imgzip/Login_SignIn/ChangePasswordController.java create mode 100644 src/imgzip/Login_SignIn/ChangePasswordSuccessfullyController.java create mode 100644 src/imgzip/Login_SignIn/FindPassword.java create mode 100644 src/imgzip/Login_SignIn/FindPasswordController.java create mode 100644 src/imgzip/Login_SignIn/GlobalStringManager.java create mode 100644 src/res/driver/mysql-connector-java-8.0.16.jar create mode 100644 src/res/icon/Happyface.png create mode 100644 src/res/icon/sad face.png create mode 100644 src/res/icon/think face.jpg create mode 100644 src/res/icon/think face.png diff --git a/JavaProgrem.iml b/JavaProgrem.iml index fc860bb..2a44138 100644 --- a/JavaProgrem.iml +++ b/JavaProgrem.iml @@ -10,7 +10,7 @@ - + diff --git a/src/fxml/ChangePassword.fxml b/src/fxml/ChangePassword.fxml new file mode 100644 index 0000000..ea554f1 --- /dev/null +++ b/src/fxml/ChangePassword.fxml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/fxml/ChangePasswordSuccessfully.fxml b/src/fxml/ChangePasswordSuccessfully.fxml new file mode 100644 index 0000000..537a763 --- /dev/null +++ b/src/fxml/ChangePasswordSuccessfully.fxml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/fxml/CreateAccount.fxml b/src/fxml/CreateAccount.fxml index 5a6861e..bf252fa 100644 --- a/src/fxml/CreateAccount.fxml +++ b/src/fxml/CreateAccount.fxml @@ -18,7 +18,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -60,7 +60,11 @@ - + + + + + @@ -68,9 +72,9 @@ - + - + @@ -85,7 +89,7 @@ - + diff --git a/src/fxml/CreateSuccessfully.fxml b/src/fxml/CreateSuccessfully.fxml index 32d2db7..6bd2fcd 100644 --- a/src/fxml/CreateSuccessfully.fxml +++ b/src/fxml/CreateSuccessfully.fxml @@ -15,26 +15,26 @@ - + + + + - - + - diff --git a/src/imgzip/Login_SignIn/ChangePassword.java b/src/imgzip/Login_SignIn/ChangePassword.java index 43fc2b4..5e1cbc9 100644 --- a/src/imgzip/Login_SignIn/ChangePassword.java +++ b/src/imgzip/Login_SignIn/ChangePassword.java @@ -4,9 +4,13 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.stage.Stage; - +/** + @Author: 肖尧 + @Date: 2019.12.12 + */ public class ChangePassword { @@ -15,6 +19,12 @@ public class ChangePassword { try { Parent root = FXMLLoader.load(getClass().getResource("/fxml/ChangePassword.fxml")); + Button change = (Button)root.lookup("#changeThePassword"); + change.setDisable(true); + + Label different = (Label)root.lookup("#checkThePassword"); + different.setVisible(false); + Stage primaryStage = new Stage(); primaryStage.setTitle("Verify your ID"); primaryStage.setScene(new Scene(root, 607, 500)); @@ -34,7 +44,7 @@ class ChangePasswordSuccessfully{ Parent root = FXMLLoader.load(getClass().getResource("/fxml/ChangePasswordSuccessfully.fxml")); Stage primaryStage = new Stage(); primaryStage.setTitle("Verify your ID"); - primaryStage.setScene(new Scene(root, 607, 500)); + primaryStage.setScene(new Scene(root, 638, 400)); primaryStage.show(); }catch (Exception e){ diff --git a/src/imgzip/Login_SignIn/ChangePasswordController.java b/src/imgzip/Login_SignIn/ChangePasswordController.java index 43cfcc4..599611e 100644 --- a/src/imgzip/Login_SignIn/ChangePasswordController.java +++ b/src/imgzip/Login_SignIn/ChangePasswordController.java @@ -24,7 +24,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ResourceBundle; - +/** + @Author: 肖尧 + @Date: 2019.12.12 + */ public class ChangePasswordController { @FXML @@ -36,8 +39,15 @@ public class ChangePasswordController { @FXML Label checkThePassword = new Label(); - public void upDatePassword(){ + @FXML + Button changeThePassword = new Button(); + + + /** + * 点击按钮后,更改密码,并检查是否更改成功。 + */ + public void upDatePassword(){ String a = GlobalStringManager.getAccount(); DataBaseController changeInstruction = new DataBaseController(); @@ -57,6 +67,8 @@ public class ChangePasswordController { new ChangePasswordSuccessfully(); stage.close(); }else { + + System.out.println("123"); } @@ -70,14 +82,49 @@ public class ChangePasswordController { } } + /** + * 检查第一次输入的密码和第二次输入的密码是否相同,以及两个密码框是否为空。 + * 如果相同或者为空,则无法点击按钮,并会有提示。 + */ + public void checkPasswordTheSame(){ + if("".equals(password.getText()) || "".equals(checkPassword.getText())){ + if(!changeThePassword.isDisable()){ + changeThePassword.setDisable(true); + } + if(checkThePassword.isVisible()){ + checkThePassword.setVisible(false); + } + + + }else{ + if(password.getText().equals(checkPassword.getText())){ + if(changeThePassword.isDisable()){ + changeThePassword.setDisable(false); + } + if(checkThePassword.isVisible()){ + checkThePassword.setVisible(false); + } + + } + if(!password.getText().equals(checkPassword.getText())){ + if(!changeThePassword.isDisable()){ + changeThePassword.setDisable(true); + } + + if(!checkThePassword.isVisible()){ + checkThePassword.setVisible(true); + } + } + + } } diff --git a/src/imgzip/Login_SignIn/ChangePasswordSuccessfullyController.java b/src/imgzip/Login_SignIn/ChangePasswordSuccessfullyController.java index 0350e3b..d746400 100644 --- a/src/imgzip/Login_SignIn/ChangePasswordSuccessfullyController.java +++ b/src/imgzip/Login_SignIn/ChangePasswordSuccessfullyController.java @@ -1,4 +1,46 @@ package imgzip.Login_SignIn; +import javafx.application.Platform; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.control.Alert; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebView; +import javafx.stage.Stage; +import sun.misc.Resource; + +import java.awt.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ResourceBundle; +/** + @Author: 肖尧 + @Date: 2019.12.12 + */ public class ChangePasswordSuccessfullyController { + + @FXML + Button SignUp = new Button(); + + + /** + * 返回登录页面 + */ + public void backToLogin(){ + Stage stage = (Stage) SignUp.getScene().getWindow(); + new LoginBeginner(); + stage.close(); + } + } diff --git a/src/imgzip/Login_SignIn/CreateAccount.java b/src/imgzip/Login_SignIn/CreateAccount.java index 903a829..7cd1b38 100644 --- a/src/imgzip/Login_SignIn/CreateAccount.java +++ b/src/imgzip/Login_SignIn/CreateAccount.java @@ -1,31 +1,187 @@ package imgzip.Login_SignIn; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.scene.control.TextField; import javafx.stage.Stage; +import javafx.scene.control.CheckBox; +import java.util.regex.*; import javafx.scene.control.Label; +import java.sql.ResultSet; + /** @Author: 肖尧 @Date: 2019.12.4 */ + public class CreateAccount { + boolean judgeAccountExists = false; + boolean judgeEmialexist = false; + public CreateAccount(){ try { Parent root = FXMLLoader.load(getClass().getResource("/fxml/CreateAccount.fxml")); Label already = (Label)root.lookup("#Al"); - already.setVisible(false); - Label already2 = (Label)root.lookup("#Al2"); - already2.setVisible(false); - Button createAccount = (Button)root.lookup("#createAccount"); + TextField userName = (TextField)root.lookup("#userName"); + TextField email = (TextField)root.lookup("#email"); + CheckBox agree = (CheckBox)root.lookup("#agree"); + + already.setVisible(false); + already2.setVisible(false); createAccount.setDisable(true); + + userName.focusedProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + + if("".equals(userName.getText())){ + + }else { + DataBaseController createAccountInstruction = new DataBaseController(); + ResultSet rs = null; + ResultSet rs2 = null; + + try { + /** + 第一步,检查数据库中是否有该账号存在 + */ + String currentInstruction = "SELECT pwd FROM login WHERE userName=" + "'" + userName.getText().trim() + "'"; + rs = createAccountInstruction.queryExcecute(currentInstruction); + + /** + * 第二步: + * ①如果账号为空,则无法点击注册按钮。 + * ②如果账号存在,无法点击。 + * ③如果账号不存在,邮箱存在,无法点击。 + * ④如果账号邮箱都不存在,但是未同意服务条款,无法点击。 + * ⑤如果账号邮箱都不存在,且同意了服务条款,才可被点击。 + */ + + if("".equals(userName.getText())){ + createAccount.setDisable(true); + + }else { + if (rs.next()) { + judgeAccountExists = true; + already.setVisible(true); + + if(!createAccount.isDisable()){ + createAccount.setDisable(true); + + } + }else{ + judgeAccountExists = false; + already.setVisible(false); + + if(!judgeEmialexist && agree.isSelected()){ + createAccount.setDisable(false); + + } + + } + + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + createAccountInstruction.close(); + } + } + } + }); + + email.focusedProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + + if(checkIfIsEmail(email.getText())){ + + if(already2.getText().equals("Invalid email!")){ + already2.setText("Already taken!!"); + } + + if (already2.isVisible()){ + already2.setVisible(false); + } + + DataBaseController createAccountInstruction = new DataBaseController(); + ResultSet rs = null; + ResultSet rs2 = null; + try { + String currentInstruction2 = "SELECT pwd FROM login WHERE email=" + "'" + email.getText().trim() + "'"; + rs2 = createAccountInstruction.queryExcecute(currentInstruction2); + + /** + * 第二步: + * ①如果账号为空,则无法点击注册按钮。 + * ②如果账号存在,无法点击。 + * ③如果账号不存在,邮箱存在,无法点击。 + * ④如果账号邮箱都不存在,但是未同意服务条款,无法点击。 + * ⑤如果账号邮箱都不存在,且同意了服务条款,才可被点击。 + */ + if ("".equals(email.getText())){ + createAccount.setDisable(true); + + }else { + if (rs2.next()) { + judgeEmialexist = true; + already2.setVisible(true); + + if(!createAccount.isDisable()){ + createAccount.setDisable(true); + + } + }else{ + judgeEmialexist = false; + already2.setVisible(false); + + if(!judgeAccountExists && agree.isSelected()){ + createAccount.setDisable(false); + + } + + } + + } + } catch (Exception e) { + e.printStackTrace(); + + } finally { + createAccountInstruction.close(); + + } + + }else{ + + if("Already taken!!".equals(already2.getText())){ + already2.setText("Invalid email!"); + } + + if("".equals(already2.getText())){ + already2.setVisible(false); + + }else { + + + + + + } + } + } + }); + + Stage primaryStage = new Stage(); primaryStage.setTitle("Create an Account"); primaryStage.setScene(new Scene(root, 600.0000999999975, 633)); @@ -36,6 +192,20 @@ public class CreateAccount { } } + + + public boolean checkIfIsEmail(String email){ + + String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; + + Pattern regex = Pattern.compile(check); + Matcher matcher = regex.matcher(email); + boolean isMatched = matcher.matches(); + + return isMatched; + } + + } class CreateSuccessfully{ diff --git a/src/imgzip/Login_SignIn/CreateAccountController.java b/src/imgzip/Login_SignIn/CreateAccountController.java index 80e087d..5d0cb6f 100644 --- a/src/imgzip/Login_SignIn/CreateAccountController.java +++ b/src/imgzip/Login_SignIn/CreateAccountController.java @@ -19,7 +19,7 @@ import java.sql.SQLException; /** @Author: 肖尧 - @Date: 2019.12.4 + @Date: 2019.12.12 */ public class CreateAccountController { @@ -59,7 +59,7 @@ public class CreateAccountController { */ public void backToLogin() { Stage stage = (Stage) signIn.getScene().getWindow(); - new Loginbeginner(); + new LoginBeginner(); stage.close(); } @@ -220,7 +220,6 @@ public class CreateAccountController { createAccountInstruction.close(); } - } /** @@ -237,7 +236,6 @@ public class CreateAccountController { if(!agree.isSelected() || userNmae || emial ){ createAccount.setDisable(true); - } } diff --git a/src/imgzip/Login_SignIn/CreateSuccessfullyController.java b/src/imgzip/Login_SignIn/CreateSuccessfullyController.java index 1b8cf0c..2bbc7bd 100644 --- a/src/imgzip/Login_SignIn/CreateSuccessfullyController.java +++ b/src/imgzip/Login_SignIn/CreateSuccessfullyController.java @@ -21,7 +21,7 @@ public class CreateSuccessfullyController{ */ public void backToLogin() { Stage stage = (Stage) signUp.getScene().getWindow(); - new Loginbeginner(); + new LoginBeginner(); stage.close(); } diff --git a/src/imgzip/Login_SignIn/FindPasswordController.java b/src/imgzip/Login_SignIn/FindPasswordController.java index ae879f2..cc272cb 100644 --- a/src/imgzip/Login_SignIn/FindPasswordController.java +++ b/src/imgzip/Login_SignIn/FindPasswordController.java @@ -118,7 +118,7 @@ public class FindPasswordController { public void backToSignIn(){ Stage stage = (Stage) verify.getScene().getWindow(); - new Loginbeginner(); + new LoginBeginner(); stage.close(); } } diff --git a/src/imgzip/Login_SignIn/GlobalStringManager.java b/src/imgzip/Login_SignIn/GlobalStringManager.java index 7ff8579..f36ce94 100644 --- a/src/imgzip/Login_SignIn/GlobalStringManager.java +++ b/src/imgzip/Login_SignIn/GlobalStringManager.java @@ -2,6 +2,8 @@ package imgzip.Login_SignIn; public class GlobalStringManager { static String account = ""; + static String emial = ""; + static String pic = ""; public static void setAccount(String account) { GlobalStringManager.account = account; @@ -10,4 +12,21 @@ public class GlobalStringManager { public static String getAccount() { return account; } + + public static void setEmial(String emial) { + GlobalStringManager.emial = emial; + } + + public static void setPic(String pic) { + GlobalStringManager.pic = pic; + } + + public static String getEmial() { + return emial; + } + + public static String getPic() { + return pic; + } + } diff --git a/src/imgzip/Login_SignIn/Login.java b/src/imgzip/Login_SignIn/Login.java index 6037e20..d6ce96c 100644 --- a/src/imgzip/Login_SignIn/Login.java +++ b/src/imgzip/Login_SignIn/Login.java @@ -13,7 +13,9 @@ import javafx.scene.control.TextField; import javafx.scene.control.PasswordField; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; +import javafx.scene.control.Label; +import java.awt.*; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.io.BufferedReader; @@ -31,19 +33,22 @@ public class Login extends Application { public void start(Stage primaryStage) throws Exception{ try { - Parent root = FXMLLoader.load(getClass().getResource("/fxml/Login.fxml")); TextField account = (TextField)root.lookup("#Account"); PasswordField password = (PasswordField)root.lookup("#password"); CheckBox remember = (CheckBox)root.lookup("#remember"); Button logIn = (Button)root.lookup("#Login"); - + Label passwordWrong = (Label)root.lookup("#passwordWrong"); /** 在页面开启之前检查上一次登录时是否记住了密码, 如果上一次登录点击了记住密码,则在本次打开时会将账号和密码写入 */ + passwordWrong.setVisible(false); + + + try { FileReader fr = new FileReader("src/txtFile/RememberAccount&Password.txt"); @@ -150,7 +155,5 @@ class Loginbeginner{ e.printStackTrace(); } - } - } \ No newline at end of file diff --git a/src/imgzip/Login_SignIn/LoginBeginner.java b/src/imgzip/Login_SignIn/LoginBeginner.java new file mode 100644 index 0000000..6aa9308 --- /dev/null +++ b/src/imgzip/Login_SignIn/LoginBeginner.java @@ -0,0 +1,72 @@ +package imgzip.Login_SignIn; + +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; +import javafx.stage.Stage; + +import java.io.BufferedReader; +import java.io.FileReader; + +public class LoginBeginner { + public LoginBeginner(){ + try { + Stage primaryStage = new Stage(); + Parent root = FXMLLoader.load(getClass().getResource("/fxml/Login.fxml")); + + TextField account = (TextField)root.lookup("#Account"); + PasswordField password = (PasswordField)root.lookup("#password"); + CheckBox remember = (CheckBox)root.lookup("#remember"); + Button logIn = (Button)root.lookup("#Login"); + + + /** + 在页面开启之前检查上一次登录时是否记住了密码, + 如果上一次登录点击了记住密码,则在本次打开时会将账号和密码写入 + */ + try { + + FileReader fr = new FileReader("src/txtFile/RememberAccount&Password.txt"); + BufferedReader br = new BufferedReader(fr); + + String line = ""; + line = br.readLine(); + + + String[] judge = line.split("\\|"); + String truejudge = "true"; + int accountIndex = 0; + int passwordIndex = 1; + int judgeIndex = 2; + + if(judge[judgeIndex].equals(truejudge) ){ + account.setText(judge[accountIndex]); + password.appendText(judge[passwordIndex]); + + remember.setSelected(true); + logIn.setDisable(false); + + } + + br.close(); + fr.close(); + + }catch (Exception e){ + e.printStackTrace(); + + } + + primaryStage.setTitle("XXX login"); + primaryStage.setScene(new Scene(root, 638, 400)); + primaryStage.show(); + + }catch (Exception e){ + e.printStackTrace(); + + } + } +} diff --git a/src/imgzip/Login_SignIn/LoginController.java b/src/imgzip/Login_SignIn/LoginController.java index e2fa0e8..d2795a7 100644 --- a/src/imgzip/Login_SignIn/LoginController.java +++ b/src/imgzip/Login_SignIn/LoginController.java @@ -2,10 +2,7 @@ package imgzip.Login_SignIn; import javafx.application.Platform; import javafx.fxml.FXML; -import javafx.scene.control.Alert; -import javafx.scene.control.Button; -import javafx.scene.control.TextField; -import javafx.scene.control.CheckBox; +import javafx.scene.control.*; import javafx.stage.Stage; import java.io.BufferedReader; @@ -50,6 +47,8 @@ public class LoginController { @FXML private Button createAccount; + @FXML + private Label passwordWrong; /** @@ -69,6 +68,10 @@ public class LoginController { }else if ((!stringAccount.equals(ifEmpty) && !stringPassword.equals(ifEmpty))){ login.setDisable(false); } + + if(passwordWrong.isVisible()){ + passwordWrong.setVisible(false); + } } @@ -109,19 +112,17 @@ public class LoginController { remember(); //登入主页面,待定 + if ((passwordWrong.isVisible())){ + passwordWrong.setVisible(false); + } System.out.println("登录1"); }else{ - new WrongPassword(); - Stage stage = (Stage)createAccount.getScene().getWindow(); - stage.close(); + passwordWrong.setVisible(true); } }else { - new WrongPassword(); - Stage stage = (Stage)createAccount.getScene().getWindow(); - stage.close(); - + passwordWrong.setVisible(true); } }catch (SQLException e){ diff --git a/src/txtFile/RememberAccount&Password.txt b/src/txtFile/RememberAccount&Password.txt index 5c847cd..8d940e7 100644 --- a/src/txtFile/RememberAccount&Password.txt +++ b/src/txtFile/RememberAccount&Password.txt @@ -1 +1 @@ -13609013530|xiaoyaozizai|true +admin|12345|true -- Gitee