本文整理匯總了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();
}