diff --git a/client/src/main/java/com/epri/fx/client/AppStartup.java b/client/src/main/java/com/epri/fx/client/AppStartup.java index 7d36593..7d8f1fa 100644 --- a/client/src/main/java/com/epri/fx/client/AppStartup.java +++ b/client/src/main/java/com/epri/fx/client/AppStartup.java @@ -87,7 +87,7 @@ public class AppStartup extends Application { stage.show(); - scene.getStylesheets().addAll(JFoenixResources.load("/css/app-fonts.css").toExternalForm(),AppStartup.class.getResource("/css/app.css").toExternalForm(),AppStartup.class.getResource("/css/login.css").toExternalForm()); + scene.getStylesheets().addAll(JFoenixResources.load("/css/app-fonts.css").toExternalForm(),AppStartup.class.getResource("/css/login.css").toExternalForm(),AppStartup.class.getResource("/css/app.css").toExternalForm()); } diff --git a/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java b/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java index 1e5aa50..7e5b52c 100644 --- a/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java +++ b/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java @@ -19,6 +19,7 @@ import com.jfoenix.controls.JFXProgressBar; import com.jfoenix.controls.JFXTextField; import com.jfoenix.svg.SVGGlyph; import com.jfoenix.svg.SVGGlyphLoader; +import com.jfoenix.validation.RegexValidator; import io.datafx.controller.ViewController; import io.datafx.controller.flow.FlowException; import io.datafx.controller.flow.action.ActionMethod; @@ -31,6 +32,7 @@ import io.datafx.controller.util.VetoException; import io.datafx.core.concurrent.ProcessChain; import javafx.animation.*; import javafx.beans.binding.Bindings; +import javafx.beans.binding.BooleanBinding; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.value.ChangeListener; @@ -103,6 +105,14 @@ public class LoginController { private JFXTextField userNameTextField; @FXML private JFXPasswordField passWordTextField; + @FXML + private JFXTextField reUserNameTextField; + @FXML + private JFXPasswordField rePwdTextField; + @FXML + private JFXPasswordField rePwd2TextField; + @FXML + private RegexValidator regexValidatorPwd2; //翻转角度 private DoubleProperty angleProperty = new SimpleDoubleProperty(Math.PI / 2); //正面翻转特效 @@ -127,6 +137,8 @@ public class LoginController { @FXML @ActionTrigger("login") private JFXButton loginBut; + @FXML + private JFXButton registeredBut; @FXMLViewFlowContext private ViewFlowContext flowContext; @@ -175,7 +187,7 @@ public class LoginController { registeredPane.managedProperty().bind(registeredPane.visibleProperty()); initAnimation(); - loadingImage(); +// loadingImage(); initAction(); } @@ -301,10 +313,53 @@ public class LoginController { } }); + reUserNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> { + if (!newVal) { + reUserNameTextField.validate(); + } + + + }); + rePwdTextField.focusedProperty().addListener((o, oldVal, newVal) -> { + if (!newVal) { + rePwdTextField.validate(); + } + }); + rePwd2TextField.focusedProperty().addListener((o, oldVal, newVal) -> { + if (!newVal) { + regexValidatorPwd2.setRegexPattern("^" + rePwdTextField.getText() + "$"); + rePwd2TextField.validate(); + } + }); + + reUserNameTextField.textProperty().addListener((observable, oldValue, newValue) -> { + reUserNameTextField.validate(); + }); + rePwdTextField.textProperty().addListener((o, oldVal, newVal) -> { + rePwdTextField.validate(); + + }); + rePwd2TextField.textProperty().addListener((o, oldVal, newVal) -> { + regexValidatorPwd2.setRegexPattern("^" + rePwdTextField.getText() + "$"); + rePwd2TextField.validate(); + }); + loginBut.disableProperty().bind(Bindings.or( userNameTextField.textProperty().isEqualTo(""), passWordTextField.textProperty().isEqualTo(""))); + BooleanBinding b1 = Bindings.or( + reUserNameTextField.textProperty().isEqualTo(""), + rePwdTextField.textProperty().isEqualTo("")); + + BooleanBinding b2 = Bindings.or(b1, + rePwd2TextField.textProperty().isEqualTo("")); + + BooleanBinding b3 = Bindings.or(reUserNameTextField.activeValidatorProperty().isNotNull(), rePwdTextField.activeValidatorProperty().isNotNull()); + BooleanBinding b4 = Bindings.or(b3, rePwd2TextField.activeValidatorProperty().isNotNull()); + + registeredBut.disableProperty().bind(Bindings.or(b2, b4)); + rootPane.setOnKeyPressed(event -> { if (event.getCode() == KeyCode.ENTER) { if (loginBut.isDisable() == false) { diff --git a/client/src/main/resources/css/app.css b/client/src/main/resources/css/app.css index cc4092d..98223fc 100644 --- a/client/src/main/resources/css/app.css +++ b/client/src/main/resources/css/app.css @@ -1,5 +1,8 @@ .root { + + -fx-font-family: "Microsoft YaHei"; + /**全局定义主题颜色变量 默认*/ -fx-main-base: #1B2431; -fx-card-base: #273142; @@ -753,6 +756,48 @@ -fx-font-size: 20px; } +/******************************************************************************* +* * +* Error Facade * +* * +*******************************************************************************/ + +.error-label { + -fx-text-fill: #D34336; + -fx-font-size: 0.75em; + -fx-font-weight: bold; +} + +.error-icon { + -fx-fill: #D34336; + -fx-font-size: 1.0em; +} + +.jfx-text-field:error, .jfx-password-field:error, .jfx-text-area:error, .jfx-combo-box:error { + -jfx-focus-color: #D34336; + -jfx-unfocus-color: #D34336; +} + +.jfx-text-field .error-label, .jfx-password-field .error-label, .jfx-text-area .error-label { + -fx-text-fill: #D34336; + -fx-font-size: 0.65em; + -fx-font-family: -fx-font-family +} + +.jfx-text-field .error-icon, .jfx-password-field .error-icon, .jfx-text-area .error-icon { + -fx-fill: #D34336; + -fx-font-size: 1.0em; +} + +.jfx-scroll-pane .main-header { + /*-fx-background-image: url("../bg1.jpg");*/ +} + +.jfx-scroll-pane .condensed-header { + /*-fx-background-image: url("../bg4.jpg");*/ +} + + /******************************************************************************* * * diff --git a/client/src/main/resources/css/login.css b/client/src/main/resources/css/login.css index 3c480c6..69426bf 100644 --- a/client/src/main/resources/css/login.css +++ b/client/src/main/resources/css/login.css @@ -51,6 +51,11 @@ -jfx-unfocus-color: -fx-light-text-color; } +#login-text-field:error { + -jfx-focus-color: #D34336; + -jfx-unfocus-color: #D34336; +} + #login-svg-glyph{ -jfx-size: 20px; -fx-background-color: #70665e; diff --git a/client/src/main/resources/fxml/login/login.fxml b/client/src/main/resources/fxml/login/login.fxml index 9b9b8c9..c803bb9 100644 --- a/client/src/main/resources/fxml/login/login.fxml +++ b/client/src/main/resources/fxml/login/login.fxml @@ -5,6 +5,8 @@ + + @@ -14,130 +16,218 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/src/test/java/TableViewSample.java b/client/src/test/java/TableViewSample.java new file mode 100644 index 0000000..e2a1a6d --- /dev/null +++ b/client/src/test/java/TableViewSample.java @@ -0,0 +1,104 @@ +import com.epri.fx.server.vo.UserVO; +import javafx.application.Application; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.ListProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleListProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.geometry.Insets; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.*; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; +import javafx.stage.Stage; + +/** + * + * @Description: + * + * @param: + * @return: + * @auther: liwen + * @date: 2020/11/6 6:29 下午 + */ +public class TableViewSample extends Application { + + private final TableView table = new TableView(); + + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage stage) { + Scene scene = new Scene(new Group()); + stage.setTitle("Table View Sample"); + stage.setWidth(300); + stage.setHeight(500); + + final Label label = new Label("Address Book"); + label.setFont(new Font("Arial", 20)); + + table.setEditable(true); + + for (int i = 0; i < 50; i++) { + TableColumn column = new TableColumn("C" + i); + column.setCellValueFactory(new PropertyValueFactory<>("data")); + table.getColumns().addAll(column); + + } + + ObservableList innerList = FXCollections.observableArrayList(); + ListProperty dataVaules = new SimpleListProperty<>(innerList); + + for (int i = 0; i < 1000; i++) { + dataVaules.add(new DataVaule(i)); + } + table.setTableMenuButtonVisible(true); + table.setBorder(new Border(new BorderStroke(Color.BLACK, + BorderStrokeStyle.SOLID, + CornerRadii.EMPTY, + new BorderWidths(0, 4, 4, 4)))); + table.setItems(dataVaules); + table.setPrefSize(500, 600); + + + final VBox vbox = new VBox(); + VBox.setVgrow(table, Priority.ALWAYS); + vbox.setSpacing(5); + vbox.setPadding(new Insets(10, 0, 0, 10)); + vbox.getChildren().addAll(label, table); + + scene.setRoot(vbox); + + stage.setScene(scene); + stage.show(); + } + + public class DataVaule { + private SimpleIntegerProperty data = new SimpleIntegerProperty(); + + public DataVaule(int data) { + this.data = new SimpleIntegerProperty(data); + } + + public int getData() { + return data.get(); + } + + public SimpleIntegerProperty dataProperty() { + return data; + } + + public void setData(int data) { + this.data.set(data); + } + } +} \ No newline at end of file