jidefx-oss
jidefx-oss copied to clipboard
Visible property not honored by decorations
It seems Visible property for TextField is not honored by the associated Decorators. I have the following code snippet:
MigPane root = new MigPane("fill, hidemode 3", "", "[grow 0][grow]");
...
TextField tf = new TextField();
tf.setPromptText("enter password");
ValidationUtils.install(tf, pw);
root.add(tf);
tf.setVisible(false);
PasswordField pf = new PasswordField();
pf.setPromptText("enter password");
ValidationUtils.install(pf, pw);
root.add(pf);
cbu.addEventHandler(ActionEvent.ACTION, new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
pf.setText(null);
tf.setText(null);
}
});
ToggleButton hb = new ToggleButton("Show");
hb.addEventHandler(ActionEvent.ACTION, new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (hb.isSelected()) {
hb.setText("Show");
pf.setVisible(false);
tf.setText(pf.getText());
tf.setVisible(true);
} else {
hb.setText("Hide");
tf.setVisible(false);
pf.setText(tf.getText());
pf.setVisible(true);
}
}
});
root.add(hb, "wrap");
...
Scene s = new Scene(new DecorationPane(root));
s.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(s);
primaryStage.sizeToScene();
primaryStage.show();
Intended effect is,obviously, to have aTextField and a PasswordField sharing the same space, with a ToggleButton to toggle between them. Unfortunately the decoration icons on the top-right corner are both visible all the time since they do not overlap completely (at least error==circle/Warning==triangle). Worse yet at program start (before I hit the ToggleButton for the first time) the "invisible" TextField decoration is in a completely bogus (and very visible) position.
Is there any workaround? Am I missing something? Thanks in Advance
Are you saying hiding the node doesn't hide the corresponding decorator?
Yes. Specifically the decorating icon is still visible. Is there some way of forcing it to go away?
DecorationUtils.uninstall will hide the decorator.