import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import javax.swing.*;
import java.awt.*;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@SuppressWarnings({"all"})
public class cover extends Application{
Stage stage = new Stage();
//登录界面
GridPane login = new GridPane();
Scene loginScene = new Scene(login, 600, 500);
//注册界面
GridPane register = new GridPane();
Scene registerScene = new Scene(register, 600, 500);
//菜单界面
GridPane menu = new GridPane();
Scene menuScene = new Scene(menu, 600, 500);
//添加人员信息
GridPane addPane = new GridPane();
Scene addScene = new Scene(addPane, 600, 500);
//修改人员信息
GridPane modifyPane = new GridPane();
Scene modifyScene = new Scene(modifyPane, 600, 500);
//删除人员信息
GridPane deletePane = new GridPane();
Scene deleteScene = new Scene(deletePane, 600, 500);
//搜索人员信息
GridPane searchPane = new GridPane();
Scene searchScene = new Scene(searchPane, 600, 500);
GridPane showInfoPane = new GridPane();
Scene showInfoScene = new Scene(showInfoPane, 600, 500);
public void start(Stage primaryStage) {
Login();
Register();
Menu();
add();
modify();
delete();
search();
showInfo();
stage.setScene(loginScene);
stage.setTitle("大学生感悟和成长目标系统");
stage.setResizable(false);
stage.show();
}
//登录界面
void Login() {
Label title = new Label("LoginPage");
title.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 30));
Label lable_1 = new Label("Account:");
lable_1.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 15));
Label lable_2 = new Label("Password:");
lable_2.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 15));
Label warn = new Label("账号或密码错误");
lable_1.centerShapeProperty();
lable_2.centerShapeProperty();
warn.setTextFill(Color.RED);
warn.setVisible(false);
warn.setFont(Font.font("T", FontPosture.ITALIC, 20));
TextField field_1 = new TextField();
PasswordField field_2 = new PasswordField();
Button loginButton = new Button("Login");
loginButton.setTranslateX(100);
loginButton.setTranslateY(320);
Button registerButton = new Button("Register");
registerButton.setTranslateX(320);
registerButton.setTranslateY(320);
Button tipButton1 = new Button("账号:jiangxinran");
Button tipButton2 = new Button("密码:123456");
tipButton1.setTranslateX(100);
tipButton1.setTranslateY(250);
tipButton2.setTranslateX(300);
tipButton2.setTranslateY(250);
login.setHgap(20);
login.setVgap(20);
login.setPadding(new Insets(0, 10, 10, 30));
login.add(title, 4, 3);
login.add(lable_1, 3, 4);
login.add(lable_2, 3, 5);
login.add(field_1, 4, 4);
login.add(field_2, 4, 5);
login.add(warn, 4, 6);
login.getChildren().addAll(loginButton, registerButton, tipButton1, tipButton2);
login.setStyle("-fx-background-image: url(" + "file:src/image/pro.png" + "); "
+ "-fx-background-position: center center; " + "-fx-background-repeat: stretch;"
+ "-fx-background-color: transparent;" + "-fx-background-size: 850px;");
//登录事件
loginButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
if (account.test_login(field_1.getText(), field_2.getText()) == 1) {
stage.setScene(menuScene);
} else {
warn.setVisible(true);
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
//注册事件
registerButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
warn.setVisible(false);
stage.setScene(registerScene);
}
});
}
//注册页面
void Register (){
Label title = new Label("注册");
title.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 35));
Label user = new Label("用户名:");
user.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 20));
Label password = new Label("密码:");
password.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 20));
Label comfirm = new Label("确认密码:");
comfirm.setFont(Font.font("T", FontWeight.LIGHT, FontPosture.ITALIC, 20));
Label comfirmWarn = new Label("两次密码不一样");
comfirmWarn.setTextFill(Color.RED);
comfirmWarn.setVisible(false);
comfirmWarn.setFont(Font.font("T", FontPosture.ITALIC, 20));
Label repeatWarn = new Label("该账号已存在");
repeatWarn.setTextFill(Color.RED);
repeatWarn.setVisible(false);
repeatWarn.setFont(Font.font("T", FontPosture.ITALIC, 20));
TextField field_1 = new TextField();
PasswordField field_2 = new PasswordField();
PasswordField field_3 = new PasswordField();
Button registerButton = new Button("注册");
registerButton.setTranslateX(30);
registerButton.setTranslateY(300);
Button returnButton = new Button("返回");
returnButton.setTranslateX(250);
returnButton.setTranslateY(300);
register.setHgap(20);
register.setVgap(20);
register.setPadding(new Insets(20, 10, 10, 100));
register.add(title, 1, 0);
register.add(user, 0, 2);
register.add(password, 0, 4);
register.add(comfirm, 0, 6);
register.add(field_1, 1, 2);
register.add(field_2, 1, 4);
register.add(field_3, 1, 6);
register.add(repeatWarn, 1, 7);
register.add(comfirmWarn, 1, 7);
register.getChildren().addAll(registerButton, returnButton);
register.setStyle("-fx-background-image: url(" + "file:src/image/zhuce.png" + "); "
+ "-fx-background-position: center center; " + "-fx-background-repeat: stretch;"
+ "-fx-background-color: transparent;" + "-fx-background-size: 850px;");
//返回按钮
returnButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stage.setScene(loginScene);
comfirmWarn.setVisible(false);
repeatWarn.setVisible(false);
}
});
//注册按钮
registerButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
if(field_2.getText() != field_3.getText()) {
if(account.test_fileExist(field_1.getText()) == 1) {
account.test_register(field_1.getText(), field_2.getText());
stage.setScene(loginScene);
comfirmWarn.setVisible(false);
repeatWarn.setVisible(false);
} else {
comfirmWarn.setVisible(false);
repeatWarn.setVisible(true);
}
} else {
comfirmWarn.setVisible(true);
}
} catch(IOException e) {
e.printStackTrace();
}
//删除
field_1.setText("");
field_2.setText("");
field_3.setText("");
}
});
}
//菜单界面
void Menu() {
Button add = new Button("Add Event");
Button modify = new Button("Modify Event");
Button delete = new Button("Delete Event");
Button search = new Button("Search Event");
Button showInfo = new Button("Show All Events");
menu.setHgap(20);
menu.setVgap(20);
menu.setPadding(new Insets(0, 10, 10, 10));
menu.add(add, 9, 8);
menu.add(modify, 9, 9);
menu.add(delete, 9, 10);
menu.add(search, 9, 11);
menu.add(showInfo,9,6);
menu.setStyle("-fx-background-image: url(" + "file:src/image/pro.png" + ");