下面列出了怎么用javafx.scene.control.ComboBoxBase的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* {@inheritDoc}
*/
@Override
protected void eval() {
if (srcControl.get() instanceof TextInputControl) {
evalTextInputField();
}
if (srcControl.get() instanceof ComboBoxBase) {
evalComboBoxField();
}
}
@Override
@FxThread
public void start(@NotNull Stage stage) throws Exception {
JfxApplication.instance = this;
this.stage = stage;
addWindow(stage);
try {
// initialize javaFX events in javaFX thread.
ArrayFactory.asArray(ComboBoxBase.ON_SHOWN);
var resourceManager = ResourceManager.getInstance();
resourceManager.reload();
var initializationManager = InitializationManager.getInstance();
initializationManager.onBeforeCreateJavaFxContext();
var pluginManager = PluginManager.getInstance();
pluginManager.handlePlugins(editorPlugin -> editorPlugin.register(CssRegistry.getInstance()));
LogView.getInstance();
SvgImageLoaderFactory.install();
ImageIO.read(getClass().getResourceAsStream("/ui/icons/test/test.jpg"));
var icons = stage.getIcons();
icons.add(new Image("/ui/icons/app/256x256.png"));
icons.add(new Image("/ui/icons/app/128x128.png"));
icons.add(new Image("/ui/icons/app/96x96.png"));
icons.add(new Image("/ui/icons/app/64x64.png"));
icons.add(new Image("/ui/icons/app/48x48.png"));
icons.add(new Image("/ui/icons/app/32x32.png"));
icons.add(new Image("/ui/icons/app/24x24.png"));
icons.add(new Image("/ui/icons/app/16x16.png"));
var config = EditorConfig.getInstance();
stage.initStyle(StageStyle.DECORATED);
stage.setMinHeight(600);
stage.setMinWidth(800);
stage.setWidth(config.getScreenWidth());
stage.setHeight(config.getScreenHeight());
stage.setMaximized(config.isMaximized());
stage.setTitle(Config.TITLE);
stage.show();
if (!stage.isMaximized()) {
stage.centerOnScreen();
}
stage.widthProperty().addListener((observable, oldValue, newValue) -> {
if (stage.isMaximized()) return;
config.setScreenWidth(newValue.intValue());
});
stage.heightProperty().addListener((observable, oldValue, newValue) -> {
if (stage.isMaximized()) return;
config.setScreenHeight(newValue.intValue());
});
stage.maximizedProperty()
.addListener((observable, oldValue, newValue) -> config.setMaximized(newValue));
buildScene();
} catch (Throwable e) {
LOGGER.error(this, e);
throw e;
}
}
private void evalComboBoxField() {
ComboBoxBase comboField = (ComboBoxBase) srcControl.get();
Object value = comboField.getValue();
hasErrors.set(value == null || value.toString().isEmpty());
}
public <T> void waitForValue(ComboBoxBase<T> comboBoxBase) {
GuiTest.waitUntil(comboBoxBase, c -> c.getValue() != null);
}