Lookup and Identify a Scene Element
jtolotta opened this issue · 2 comments
jtolotta commented
The following creates a simple window displaying the following fields:
- proxyType (Combobox:enum)
- proxyHost (Textfield:String)
- proxyPort (Textfield:int
- proxyExclusions (Textfield:String)
The following Java code displays the content:
public class ProxyDemo extends Application {
private FXForm<Proxy> fxForm;
private StackPane mainPane = new StackPane();
static enum ProxyType {
DIRECT, HTTP, HTTPS, FTP, SOCKS;
}
static class Proxy {
private final ObjectProperty<ProxyType> proxyType = new SimpleObjectProperty<ProxyType>();
private final StringProperty proxyHost = new SimpleStringProperty();
private final IntegerProperty proxyPort = new SimpleIntegerProperty();
private final StringProperty proxyExclusions = new SimpleStringProperty();
public Proxy(ProxyType proxyType, String proxyHost, int proxyPort, String proxyExclusions) {
this.proxyType.set(proxyType);
this.proxyHost.set(proxyHost);
this.proxyPort.set(proxyPort);
this.proxyExclusions.set(proxyExclusions);
}
public ProxyType getProxyType() {
return proxyType.get();
}
public String getProxyHost() {
return proxyHost.get();
}
public int getProxyPort() {
return proxyPort.get();
}
public String getProxyExclusions() {
return proxyExclusions.get();
}
}
@SuppressWarnings("unchecked")
@Override
public void start(Stage primaryStage) throws Exception {
Proxy proxy = new Proxy(ProxyType.DIRECT, "", 0, "");
fxForm = new FXFormBuilder<>().source(proxy).build();
mainPane.getChildren().addAll(fxForm);
Scene root = new Scene(mainPane);
primaryStage.setTitle("Demo");
primaryStage.setScene(root);
primaryStage.show();
}
public static void main(String... args) {
ProxyDemo.launch(args);
}
}
The following is my attempt to lookup the Proxy Type.
fxForm.getScene().lookup("#proxyType");
It is my intention to Disable the fields when the Proxy Type is DIRECT, otherwise enable them.
Is the "proxyType" a Combobox type?
What is the ID of this field that FXForm2 assigns?
How does FXForm2 assign the IDs?
amischler commented
You can access to the editor of the proxyType field using the #proxyType-form-editor
id.
See this wiki page for more informations about classes and ids assigned to the form nodes.
jtolotta commented
Thanks that cleared this up.