本文整理汇总了Java中javafx.util.converter.FormatStringConverter类的典型用法代码示例。如果您正苦于以下问题:Java FormatStringConverter类的具体用法?Java FormatStringConverter怎么用?Java FormatStringConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FormatStringConverter类属于javafx.util.converter包,在下文中一共展示了FormatStringConverter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFormatStringConverter
import javafx.util.converter.FormatStringConverter; //导入依赖的package包/类
/**
* Tests format string converter and checks that transformation is performed
* properly
*/
@Smoke
@Test(timeout = 300000)
public void testFormatStringConverter() throws InterruptedException {
setPropertyBySlider(SettingType.SETTER, Properties.prefWidth, 150);
int itemsCount = 3;
String prefix = "value #";
final List<String> testedValues = new ArrayList<String>(itemsCount);
for (int i = 0; i < itemsCount; i++) {
testedValues.add(prefix + i);
}
final String pattern = "Before text. {0} After text.";
MessageFormat m = new MessageFormat(pattern);
final Format fmt = new ComboBoxApp.MyMessageFormat(m);
//Set format string converter
new GetAction<Object>() {
@Override
public void run(Object... parameters) throws Exception {
testedControl.getControl().setConverter(new FormatStringConverter<String>(fmt));
//populate control
testedControl.getControl().getItems().addAll(testedValues);
}
}.dispatch(Root.ROOT.getEnvironment());
setPropertyByToggleClick(SettingType.SETTER, Properties.editable, true);
//#toString
for (int i = 0; i < testedValues.size(); i++) {
testedControl.as(Selectable.class).selector().select(testedValues.get(i));
assertEquals(getTextFieldText(), fmt.format(testedValues.get(i)));
}
//#fromString
for (int i = 0; i < testedValues.size(); i++) {
testedControl.as(Text.class).clear();
testedControl.as(Text.class).type(fmt.format(testedValues.get(i)));
testedControl.keyboard().pushKey(KeyboardButtons.ENTER);
checkTextFieldText(Properties.value, testedValues.get(i));
}
doNextResetHard();
}