I have the following code:
@ParticleView(isDefault=true, name="login")
public class LoginView extends FXMLView {
public LoginView() {
super(LoginView.class.getResource("login.fxml"));
}
@Override
public void start() {
((LoginController) getController()).postInit();
}
@Override
public void stop() {
((LoginController) getController()).dispose();
}
}
And the controller relevant code is:
public class LoginController {
@Inject
ParticleApplication app;
@Inject
private ViewManager viewManager;
@Inject
private StateManager stateManager;
@Inject
private MenuBar menuBar;
@Inject
private ToolBar toolBar;
@Inject
private StatusBar statusBar;
@FXML
private TextField txfUsuario;
@FXML
private PasswordField txfPassword;
public void initialize() {
ActionMap.register(this);
}
public void postInit() {
app.setShowCloseConfirmation(false);
toolBar.setVisible(false);
menuBar.setVisible(false);
}
}
The menubar is not visible (but the space is still there) but the toolbar is still visible.
Any sugestions?
If you run this short test with a regular JavaFX Application, you will notice the same behavior:
According to JavaDoc for a node's
managed
property:This means the borderpane's top region keeps the preferred size given by the toolbar (which by default is managed), regardless its visibility.
When you set the visibility of a
ToolBar
to false, you need as well to release its space, by settingmanaged
to false:EDIT
In your case, you have also a
MenuBar
, and theToolBar
managed
property is already bound to its visibility, so you only need to set:Note: I've added
Platform.runLater()
: ThepostInit()
method is called before the stage is shown, so that's a way to delay it a bit and let the controls be rendered properly before dealing with their visibility.In case you want to restore their visibility, this should work as well: