登录框加入校验功能
This commit is contained in:
@@ -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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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");*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* *
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
<?import com.jfoenix.controls.JFXProgressBar?>
|
||||
<?import com.jfoenix.controls.JFXTextField?>
|
||||
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||
<?import com.jfoenix.validation.RequiredFieldValidator?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Hyperlink?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.effect.DropShadow?>
|
||||
@@ -14,130 +16,218 @@
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
|
||||
<?import com.jfoenix.validation.RegexValidator?>
|
||||
<StackPane fx:id="rootPane" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<Pane fx:id="imagePane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #3F007F;" />
|
||||
<StackPane fx:id="centerPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="450.0" prefWidth="650.0" style="-fx-background-radius: 14;">
|
||||
<children>
|
||||
<HBox fx:id="loginPane" style="-fx-background-color: #ffffff; -fx-background-radius: 14;">
|
||||
<children>
|
||||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="450.0" prefWidth="251.0" style="-fx-background-radius: 14 0 0 14; -fx-background-color: linear-gradient(#e66465, #9198e5);">
|
||||
<children>
|
||||
<Label id="login-welcome-title" layoutX="70.0" layoutY="134.0" text="欢迎" textFill="WHITE">
|
||||
<font>
|
||||
<Font size="48.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label id="login-welcome-text" layoutX="38.0" layoutY="213.0" text="登录访问您的帐户" textFill="WHITE">
|
||||
<font>
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="79.0" layoutY="419.0" text="©中国xxx∙xxx" textFill="#ffffffad" />
|
||||
</children>
|
||||
<effect>
|
||||
<DropShadow color="#000000b2" height="68.0" radius="49.0" width="130.0" />
|
||||
</effect>
|
||||
</AnchorPane>
|
||||
<AnchorPane prefHeight="450.0" prefWidth="352.0" HBox.hgrow="ALWAYS">
|
||||
<children>
|
||||
<Label id="login-title" layoutX="168.0" layoutY="45.0" text="登录">
|
||||
<font>
|
||||
<Font name="System Bold" size="33.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<JFXProgressBar fx:id="lodingBar" layoutX="66.0" layoutY="83.0" visible="false" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" />
|
||||
<JFXTextField id="login-text-field" fx:id="userNameTextField" labelFloat="true" layoutX="71.0" layoutY="126.0" prefHeight="45.0" prefWidth="260.0" promptText="用户名">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXTextField>
|
||||
<JFXPasswordField id="login-text-field" fx:id="passWordTextField" labelFloat="true" layoutX="71.0" layoutY="210.0" prefHeight="45.0" prefWidth="260.0" promptText="密码">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXPasswordField>
|
||||
<JFXToggleButton alignment="CENTER_LEFT" layoutX="66.0" layoutY="265.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="45.0" prefWidth="260.0" text="记住密码" />
|
||||
<JFXButton fx:id="loginBut" layoutX="71.0" layoutY="326.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="50.0" prefWidth="260.0" style="-fx-background-color: linear-gradient(#e66465, #9198e5); -fx-background-radius: 25;" text="登录" textFill="#fffefe">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
<Hyperlink fx:id="registeredLink" layoutX="226.0" layoutY="404.0" text="注册" />
|
||||
<Label id="login-prompt" layoutX="141.0" layoutY="408.0" text="还没有帐号?去" />
|
||||
<VBox alignment="CENTER" layoutY="302.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
|
||||
<children>
|
||||
<Label id="login-error-label" fx:id="errorLabel" alignment="CENTER" contentDisplay="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS" />
|
||||
</children>
|
||||
</VBox>
|
||||
<Label id="icon-label" fx:id="userIcon" alignment="CENTER" contentDisplay="CENTER" layoutX="296.0" layoutY="131.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="35.0" prefWidth="35.0" />
|
||||
<Label id="icon-label" fx:id="pwdIcon" alignment="CENTER" contentDisplay="CENTER" layoutX="296.0" layoutY="215.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="35.0" prefWidth="35.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="registeredPane" style="-fx-background-color: #ffffff; -fx-background-radius: 14;" visible="false">
|
||||
<children>
|
||||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="450.0" prefWidth="251.0" style="-fx-background-radius: 14 0 0 14; -fx-background-color: linear-gradient(#3F007F, #7226A5);">
|
||||
<children>
|
||||
<Label id="login-welcome-title" layoutX="70.0" layoutY="134.0" text="欢迎" textFill="WHITE">
|
||||
<font>
|
||||
<Font size="48.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label id="login-welcome-text" layoutX="38.0" layoutY="213.0" text="注册访问您的帐户" textFill="WHITE">
|
||||
<font>
|
||||
<Font size="20.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="79.0" layoutY="419.0" text="©中国xxx∙xxx" textFill="#ffffffad" />
|
||||
</children>
|
||||
<effect>
|
||||
<DropShadow color="#000000b2" height="68.0" radius="49.0" width="130.0" />
|
||||
</effect>
|
||||
</AnchorPane>
|
||||
<AnchorPane prefHeight="450.0" prefWidth="352.0" HBox.hgrow="ALWAYS">
|
||||
<children>
|
||||
<Label id="login-title" layoutX="166.0" layoutY="45.0" text="注册">
|
||||
<font>
|
||||
<Font name="System Bold" size="33.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<JFXProgressBar layoutX="66.0" layoutY="83.0" visible="false" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" />
|
||||
<JFXTextField id="login-text-field" labelFloat="true" layoutX="71.0" layoutY="122.0" prefHeight="45.0" prefWidth="260.0" promptText="用户名" AnchorPane.topAnchor="122.0">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXTextField>
|
||||
<JFXPasswordField id="login-text-field" labelFloat="true" layoutX="69.0" layoutY="197.0" prefHeight="45.0" prefWidth="260.0" promptText="密码" AnchorPane.topAnchor="197.0">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXPasswordField>
|
||||
<JFXButton layoutX="71.0" layoutY="340.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="50.0" prefWidth="260.0" style="-fx-background-color: linear-gradient(#3F007F, #7226A5); -fx-background-radius: 25;" text="注册" textFill="#fffefe">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXButton>
|
||||
<Hyperlink fx:id="loginLink" layoutX="212.0" layoutY="402.0" text="登录" />
|
||||
<Label id="login-prompt" layoutX="147.0" layoutY="406.0" text="已有帐号去" />
|
||||
<JFXPasswordField id="login-text-field" labelFloat="true" layoutX="67.0" layoutY="270.0" prefHeight="45.0" prefWidth="260.0" promptText="确认密码" AnchorPane.topAnchor="270.0">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</JFXPasswordField>
|
||||
<Label id="icon-label" fx:id="reuserIcon" alignment="CENTER" contentDisplay="CENTER" layoutX="292.0" layoutY="127.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="35.0" prefWidth="35.0" />
|
||||
<Label id="icon-label" fx:id="repwdIcon" alignment="CENTER" contentDisplay="CENTER" layoutX="292.0" layoutY="202.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="35.0" prefWidth="35.0" />
|
||||
<Label id="icon-label" fx:id="repwd2Icon" alignment="CENTER" contentDisplay="CENTER" layoutX="292.0" layoutY="275.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="35.0" prefWidth="35.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<effect>
|
||||
<DropShadow color="#0000009e" height="180.1" radius="89.9975" width="181.89" />
|
||||
</effect>
|
||||
</StackPane>
|
||||
</children>
|
||||
<children>
|
||||
<Pane fx:id="imagePane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0"
|
||||
prefWidth="200.0" style="-fx-background-color: #3F007F;"/>
|
||||
<StackPane fx:id="centerPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="450.0" prefWidth="650.0" style="-fx-background-radius: 14;">
|
||||
<children>
|
||||
<HBox fx:id="loginPane" style="-fx-background-color: #ffffff; -fx-background-radius: 14;">
|
||||
<children>
|
||||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="450.0" prefWidth="251.0"
|
||||
style="-fx-background-radius: 14 0 0 14; -fx-background-color: linear-gradient(#e66465, #9198e5);">
|
||||
<children>
|
||||
<Label id="login-welcome-title" layoutX="70.0" layoutY="134.0" text="欢迎"
|
||||
textFill="WHITE">
|
||||
<font>
|
||||
<Font size="48.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<Label id="login-welcome-text" layoutX="38.0" layoutY="213.0" text="登录访问您的帐户"
|
||||
textFill="WHITE">
|
||||
<font>
|
||||
<Font size="20.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="79.0" layoutY="419.0" text="©中国xxx∙xxx" textFill="#ffffffad"/>
|
||||
</children>
|
||||
<effect>
|
||||
<DropShadow color="#000000b2" height="68.0" radius="49.0" width="130.0"/>
|
||||
</effect>
|
||||
</AnchorPane>
|
||||
<AnchorPane prefHeight="450.0" prefWidth="352.0" HBox.hgrow="ALWAYS">
|
||||
<children>
|
||||
<Label id="login-title" layoutX="168.0" layoutY="45.0" text="登录">
|
||||
<font>
|
||||
<Font name="System Bold" size="33.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<JFXProgressBar fx:id="lodingBar" layoutX="66.0" layoutY="83.0" visible="false"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"/>
|
||||
<VBox layoutX="71.0" layoutY="96.0" prefHeight="157.0" prefWidth="260.0" spacing="45.0">
|
||||
<children>
|
||||
<JFXTextField id="login-text-field" fx:id="userNameTextField" labelFloat="true"
|
||||
maxWidth="1.7976931348623157E308" prefWidth="260.0"
|
||||
promptText="用户名">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
<validators>
|
||||
<RequiredFieldValidator message="请输入用户名">
|
||||
<FontIcon iconLiteral="fas-exclamation-triangle"/>
|
||||
</RequiredFieldValidator>
|
||||
</validators>
|
||||
</JFXTextField>
|
||||
<JFXPasswordField id="login-text-field" fx:id="passWordTextField"
|
||||
labelFloat="true" maxWidth="1.7976931348623157E308"
|
||||
promptText="密码">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
<validators>
|
||||
<RequiredFieldValidator message="请输入密码">
|
||||
<FontIcon iconLiteral="fas-exclamation-triangle"/>
|
||||
</RequiredFieldValidator>
|
||||
</validators>
|
||||
</JFXPasswordField>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="30.0"/>
|
||||
</padding>
|
||||
</VBox>
|
||||
<JFXToggleButton alignment="CENTER_LEFT" layoutX="66.0" layoutY="265.0"
|
||||
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="45.0" prefWidth="260.0" text="记住密码"/>
|
||||
<JFXButton fx:id="loginBut" layoutX="71.0" layoutY="326.0" maxHeight="-Infinity"
|
||||
maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
||||
prefHeight="50.0" prefWidth="260.0"
|
||||
style="-fx-background-color: linear-gradient(#e66465, #9198e5); -fx-background-radius: 25;"
|
||||
text="登录" textFill="#fffefe">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
</JFXButton>
|
||||
<Hyperlink fx:id="registeredLink" layoutX="226.0" layoutY="404.0" text="注册"/>
|
||||
<Label id="login-prompt" layoutX="141.0" layoutY="408.0" text="还没有帐号?去"/>
|
||||
<VBox alignment="CENTER" layoutY="302.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0">
|
||||
<children>
|
||||
<Label id="login-error-label" fx:id="errorLabel" alignment="CENTER"
|
||||
contentDisplay="CENTER" maxHeight="1.7976931348623157E308"
|
||||
maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS"/>
|
||||
</children>
|
||||
</VBox>
|
||||
<Label id="icon-label" fx:id="userIcon" alignment="CENTER" contentDisplay="CENTER"
|
||||
layoutX="301.0" layoutY="130.0" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
prefHeight="35.0" prefWidth="35.0"/>
|
||||
<Label id="icon-label" fx:id="pwdIcon" alignment="CENTER" contentDisplay="CENTER"
|
||||
layoutX="300.0" layoutY="210.0" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
prefHeight="35.0" prefWidth="35.0"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="registeredPane" style="-fx-background-color: #ffffff; -fx-background-radius: 14;"
|
||||
visible="false">
|
||||
<children>
|
||||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="450.0" prefWidth="251.0"
|
||||
style="-fx-background-radius: 14 0 0 14; -fx-background-color: linear-gradient(#3F007F, #7226A5);">
|
||||
<children>
|
||||
<Label id="login-welcome-title" layoutX="70.0" layoutY="134.0" text="欢迎"
|
||||
textFill="WHITE">
|
||||
<font>
|
||||
<Font size="48.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<Label id="login-welcome-text" layoutX="38.0" layoutY="213.0" text="注册访问您的帐户"
|
||||
textFill="WHITE">
|
||||
<font>
|
||||
<Font size="20.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="79.0" layoutY="419.0" text="©中国xxx∙xxx" textFill="#ffffffad"/>
|
||||
</children>
|
||||
<effect>
|
||||
<DropShadow color="#000000b2" height="68.0" radius="49.0" width="130.0"/>
|
||||
</effect>
|
||||
</AnchorPane>
|
||||
<AnchorPane prefHeight="450.0" prefWidth="352.0" HBox.hgrow="ALWAYS">
|
||||
<children>
|
||||
<Label id="login-title" layoutX="166.0" layoutY="45.0" text="注册">
|
||||
<font>
|
||||
<Font name="System Bold" size="33.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<JFXProgressBar layoutX="66.0" layoutY="83.0" visible="false"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"/>
|
||||
<VBox layoutX="70.0" layoutY="85.0" prefHeight="247.0" prefWidth="260.0" spacing="40.0">
|
||||
<children>
|
||||
<JFXTextField fx:id="reUserNameTextField" id="login-text-field"
|
||||
labelFloat="true"
|
||||
maxWidth="1.7976931348623157E308" promptText="用户名">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
<validators>
|
||||
<RegexValidator message="4到16位(字母,数字,下划线,减号)!"
|
||||
regexPattern="^[a-zA-Z0-9_-]{4,16}$">
|
||||
<FontIcon iconLiteral="fas-exclamation-triangle"/>
|
||||
</RegexValidator>
|
||||
</validators>
|
||||
</JFXTextField>
|
||||
<JFXPasswordField fx:id="rePwdTextField" id="login-text-field" labelFloat="true"
|
||||
maxWidth="1.7976931348623157E308" promptText="密码">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
<validators>
|
||||
<RegexValidator message="最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符!"
|
||||
regexPattern="^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^?&*? ]).*$">
|
||||
<FontIcon iconLiteral="fas-exclamation-triangle"/>
|
||||
</RegexValidator>
|
||||
</validators>
|
||||
</JFXPasswordField>
|
||||
<JFXPasswordField fx:id="rePwd2TextField" id="login-text-field"
|
||||
labelFloat="true"
|
||||
maxWidth="1.7976931348623157E308" promptText="确认密码">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
<validators>
|
||||
<RegexValidator fx:id="regexValidatorPwd2" message="两次密码不一至!">
|
||||
<FontIcon iconLiteral="fas-exclamation-triangle"/>
|
||||
</RegexValidator>
|
||||
</validators>
|
||||
</JFXPasswordField>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="30.0"/>
|
||||
</padding>
|
||||
</VBox>
|
||||
<JFXButton fx:id="registeredBut" layoutX="69.0" layoutY="340.0" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
minHeight="-Infinity" minWidth="-Infinity" prefHeight="50.0"
|
||||
prefWidth="260.0"
|
||||
style="-fx-background-color: linear-gradient(#3F007F, #7226A5); -fx-background-radius: 25;"
|
||||
text="注册" textFill="#fffefe">
|
||||
<font>
|
||||
<Font size="18.0"/>
|
||||
</font>
|
||||
</JFXButton>
|
||||
<Hyperlink fx:id="loginLink" layoutX="212.0" layoutY="401.0" text="登录"/>
|
||||
<Label id="login-prompt" layoutX="147.0" layoutY="405.0" text="已有帐号去"/>
|
||||
<Label id="icon-label" fx:id="reuserIcon" alignment="CENTER" contentDisplay="CENTER"
|
||||
layoutX="300.0" layoutY="119.0" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
prefHeight="35.0" prefWidth="35.0"/>
|
||||
<Label id="icon-label" fx:id="repwdIcon" alignment="CENTER" contentDisplay="CENTER"
|
||||
layoutX="300.0" layoutY="194.0" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
prefHeight="35.0" prefWidth="35.0"/>
|
||||
<Label id="icon-label" fx:id="repwd2Icon" alignment="CENTER" contentDisplay="CENTER"
|
||||
layoutX="300.0" layoutY="269.0" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
prefHeight="35.0" prefWidth="35.0"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<effect>
|
||||
<DropShadow color="#0000009e" height="180.1" radius="89.9975" width="181.89"/>
|
||||
</effect>
|
||||
</StackPane>
|
||||
</children>
|
||||
</StackPane>
|
||||
|
||||
104
client/src/test/java/TableViewSample.java
Normal file
104
client/src/test/java/TableViewSample.java
Normal file
@@ -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<DataVaule> innerList = FXCollections.observableArrayList();
|
||||
ListProperty<DataVaule> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user