网站建设的基本流程有哪些,wordpress产品页布局,建永久网站,建站行业消失了吗PasswordField用于密码输入。用户键入的字符通过显示回显字符串被隐藏。
创建密码字段
以下代码使用来自PasswordField类的默认构造函数创建一个密码字段#xff0c;然后为密码字段设置提示消息文本。 提示消息在字段中显示为灰色文本#xff0c;并为用户提供该字段是什么的…PasswordField用于密码输入。用户键入的字符通过显示回显字符串被隐藏。
创建密码字段
以下代码使用来自PasswordField类的默认构造函数创建一个密码字段然后为密码字段设置提示消息文本。 提示消息在字段中显示为灰色文本并为用户提供该字段是什么的提示而不使用标签控件。
PasswordField passwordField new PasswordField();
passwordField.setPromptText(Your password);
PasswordField类有setText方法来为控件设置文本字符串。对于密码字段指定的字符串由回显字符隐藏。默认情况下回显字符是一个点(或是星号)。
密码字段中的值可以通过getText()方法获取。 示例
密码字段和操作侦听器如下所示 -
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;public class Main extends Application {final Label message new Label();Overridepublic void start(Stage stage) {Group root new Group();Scene scene new Scene(root, 260, 80);stage.setScene(scene);stage.setTitle(Password Field Sample);VBox vb new VBox();vb.setPadding(new Insets(10, 0, 0, 10));vb.setSpacing(10);HBox hb new HBox();hb.setSpacing(10);hb.setAlignment(Pos.CENTER_LEFT);Label label new Label(Password);final PasswordField pb new PasswordField();pb.setOnAction(new EventHandlerActionEvent() {Overridepublic void handle(ActionEvent e) {if (!pb.getText().equals(abc)) {message.setText(Your password is incorrect!);message.setTextFill(Color.web(red));} else {message.setText(Your password has been confirmed);message.setTextFill(Color.web(black));}pb.setText();}});hb.getChildren().addAll(label, pb);vb.getChildren().addAll(hb, message);scene.setRoot(vb);stage.show();}public static void main(String[] args) {launch(args);}
}
此处为语雀视频卡片点击链接查看Video_2022-04-28_161022.wmv