我是javaFx的新手,所以请忽略我在这里的愚蠢问题我想验证(限制)用户输入3个字符(如果用户输入更多的信息,则不允许或者3个字符之后,不应该显示后者)我发现了许多验证解决方案,但它不限制最多3个字符,以及它理解的小混乱。下面是我的代码。限制用户在javafx中输入最多3个字符
public class editController {
@FXML
private TextField countrycode;
public void add(ActionEvent event) {
String ADD=countrycode.getText();
try {
if(ADD.isEmpty()){
Alert alert=new Alert(Alert.AlertType.ERROR);
alert.setHeaderText(null);
alert.setContentText("Please Fill All DATA");
alert.showAndWait();
return;
}
FXMLLoader loader =new FXMLLoader();
loader.load(getClass().getResource("/region/newCountry.fxml").openStream());
它不工作到我的代码,我不想显示超过3个字符,如果用户输入 – Rocky
我希望这段代码是帮助你!如果你在这个解决方案中解决了你的问题,那么以后不要接受帮助其他人的答案。 –
我想只有3个字符是可见的,如果用户把更多的价值,那么它不允许在输入字段 – Rocky