I am using Linux Suse 12.3, JDK 1.7.0-45, JavaFX 2.2.
my Question: why the following code does not work and how to implement the toggleShow / hide function?
here is my test code:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;
public class Test extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage stage) {
AnchorPane root = new AnchorPane();
BorderPane inner = new BorderPane();
AnchorPane.setTopAnchor(inner, 0.0);
AnchorPane.setRightAnchor(inner, 0.0);
AnchorPane.setBottomAnchor(inner, 0.0);
AnchorPane.setLeftAnchor(inner, 0.0);
final HTMLEditor center = new HTMLEditor();
final ToolBar top = new ToolBar();
final Button button = new Button("hide");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
top.setVisible(false);
}
});
center.setManaged(false);
top.getItems().add(button);
top.setManaged(false);
inner.setTop(top);
inner.setCenter(center);
root.getChildren().add(inner);
Scene scene = new Scene(root,600,400);
stage.setScene(scene);
stage.show();
}
}
what I want is the same effect as Sergeyβs decision on this question, but without changing the width / height !:
How to solve the coincidence of controls with each other belonging to two different panels
as I said, this is just test code. I tried using other layouts like BorderPane but still didn't work. I do not want to recalculate the size manually ... etc. Removing the node and adding it again is not an option for me.
What happened in my code? any idea is welcome! thanks