数字输入
The number输入组件请求用户进行简单的数字输入。它可以配置为使用Number类的任何实现。以下示例展示了如何使用该组件:
NumberInput component = new NumberInput(getTerminal(), "Enter value", 99.9, Double.class);
ResourceLoader resourceLoader = null; // getResourceLoader();
TemplateExecutor templateExecutor = null; // getTemplateExecutor();
component.setResourceLoader(resourceLoader);
component.setTemplateExecutor(templateExecutor);
NumberInputContext context = component.run(NumberInputContext.empty());
return "Got value " + context.getResultValue();
以下图片展示了典型的数字输入组件的输出:
The context对象是NumberInputContext。以下表格列出了其上下文变量:
| 键 | 描述 |
|---|---|
|
默认值,如果设置。否则,null. |
|
The default number class to use, if set. Otherwise, Integer.class. |
|
|
|
The parent context variables (see TextComponentContext 模板变量). |