AFAIK No but you can always customize the controls according to your needs. For example like
<MyTextField ... onKeyTypedFilter="#yourFilter" />
then do some reflection staff in backend. However is it worth?
문제
now i can do this
public TextField lastmonthbox;
public void initialize()throws Exception{
lastmonthbox.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() {
public void handle( KeyEvent t ) {
char ar[] = t.getCharacter().toCharArray();
char ch = ar[t.getCharacter().toCharArray().length - 1];
if (!(ch >= '0' && ch <= '9' || ch=='.')) {
System.out.println("The char you entered is not a number");
t.consume();
}
}
});
}
is there way to add eventfilter via fxml, looks like onAction="#someFunction"??
i not found any list or tutorial about all possible tags in fxml(
해결책
AFAIK No but you can always customize the controls according to your needs. For example like
<MyTextField ... onKeyTypedFilter="#yourFilter" />
then do some reflection staff in backend. However is it worth?
다른 팁
Following Uluk's answer, you can do something like this. There's no reflection required as the FXMLLoader already takes care of converting "#..." to an EventHandler object.
Note that this is just the structure: this isn't a particularly robust way of creating a numeric-only text field. For example, the user can copy and paste arbitrary text in there, using either keystrokes or the mouse.