import javafx.application.Application; import javafx.application.Launcher; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextBox; import javafx.scene.control.Tooltip; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { Launcher.launch(Main.class, args); } @Override public void start(Stage stage) { stage.setHeight(100.0); stage.setWidth(200.0); final Group root = new Group(); Scene scene = new Scene(root); TextBox tb = new TextBox(); tb.setTooltip(new Tooltip("Test")); tb.relocate(0, 30); Button button = new Button("Remove box"); button.setOnAction(new EventHandler() { public void handle(ActionEvent e) { root.getChildren().remove(1); System.gc(); } }); root.getChildren().addAll(button, tb); stage.setScene(scene); stage.setVisible(true); } }