本文整理汇总了Java中com.jfoenix.validation.RequiredFieldValidator类的典型用法代码示例。如果您正苦于以下问题:Java RequiredFieldValidator类的具体用法?Java RequiredFieldValidator怎么用?Java RequiredFieldValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequiredFieldValidator类属于com.jfoenix.validation包,在下文中一共展示了RequiredFieldValidator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.jfoenix.validation.RequiredFieldValidator; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
api = new APIConnect();
ValidatorBase require = new RequiredFieldValidator();
require.setMessage("ユーザIDは必須");
ValidatorBase validator = new UserValidator(api);
validator.setMessage("無効なユーザID");
userField.getValidators().addAll(require, validator);
userField.focusedProperty().addListener((o, oldVal, newVal)->{
if(!newVal) userField.validate();
setProblem();
});
postedCode.getEngine().load(getClass().getResource("/resources/html/ace.html").toExternalForm());
obj = (JSObject) postedCode.getEngine().executeScript("window");
try {
contest.getItems().addAll(api.getContests());
}catch(Exception e) {
getAlert(e, "コンテスト情報の取得に失敗しました。").show();
}
}
示例2: addString
import com.jfoenix.validation.RequiredFieldValidator; //导入依赖的package包/类
/**
* Add a simple String to a wizard step.
*
* @param fieldName
* @param defaultValue
* the default String the textfield will contains.
* @param prompt
* the text to show on the textfield prompt String.
* @param isRequired
* set the field required to continue
* @return
*/
@SuppressWarnings("unchecked")
public WizardStepBuilder addString(final String fieldName, final String defaultValue, final String prompt,
final boolean isRequired)
{
final JFXTextField text = new JFXTextField();
text.setPromptText(prompt);
if (isRequired)
{
final RequiredFieldValidator validator = new RequiredFieldValidator();
validator.setMessage(Translation.LANG.getTranslation("wizard.error.input_required"));
validator.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em")
.styleClass("error").build());
text.getValidators().add(validator);
}
text.focusedProperty().addListener((o, oldVal, newVal) ->
{
if (!newVal)
text.validate();
});
text.setText(defaultValue);
this.current.getData().put(fieldName, new SimpleStringProperty());
this.current.getData().get(fieldName).bind(text.textProperty());
this.current.addToValidate(text);
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(text, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
this.current.add(text, 1, this.current.getData().size() - 1);
return this;
}
示例3: folderValidator
import com.jfoenix.validation.RequiredFieldValidator; //导入依赖的package包/类
private void folderValidator() {
RequiredFieldValidator requiredFieldValidator = new RequiredFieldValidator();
selectFolderFld.getValidators().add(requiredFieldValidator);
requiredFieldValidator.setMessage("Please select destination folder");
selectFolderFld.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
selectFolderFld.validate();
}
});
selectFolderFld.textProperty().addListener((observable, oldValue, newValue) -> selectFolderFld.validate());
}
示例4: start
import com.jfoenix.validation.RequiredFieldValidator; //导入依赖的package包/类
@Override
public void start(Stage stage) {
VBox main = new VBox();
main.setSpacing(50);
TextArea javafxTextArea = new TextArea();
javafxTextArea.setPromptText("JavaFX Text Area");
main.getChildren().add(javafxTextArea);
JFXTextArea jfxTextArea = new JFXTextArea();
jfxTextArea.setPromptText("JFoenix Text Area :D");
jfxTextArea.setLabelFloat(true);
RequiredFieldValidator validator = new RequiredFieldValidator();
// NOTE adding error class to text area is causing the cursor to disapper
validator.setMessage("Please type something!");
validator.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.WARNING)
.size("1em")
.styleClass("error")
.build());
jfxTextArea.getValidators().add(validator);
jfxTextArea.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal) {
jfxTextArea.validate();
}
});
main.getChildren().add(jfxTextArea);
StackPane pane = new StackPane();
pane.getChildren().add(main);
StackPane.setMargin(main, new Insets(100));
pane.setStyle("-fx-background-color:WHITE");
final Scene scene = new Scene(pane, 800, 600);
scene.getStylesheets()
.add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
stage.setTitle("JFX Button Demo");
stage.setScene(scene);
stage.show();
}