How can I remove these(on the picture) actors if I only have access to root's Window methods getChildren() and getCells() ? I've tried somthing like this: removeActor(getCells().get(1).getTable().getCells().get(0).getTable()...getTable());

But it always return the root Table.

enter image description here


I've came to this:

Cell<FileChooser> cell = getCells().get(1);

But now it throws nonsense Exception:

Exception in thread "LWJGL Application" java.lang.ClassCastException: com.kotcrab.vis.ui.widget.file.FileChooser$11 cannot be cast to com.kotcrab.vis.ui.widget.file.FileChooser

How class cannot be cast to its own type?

  • \$\begingroup\$ Just to the last sentence: the cast is not to its type, but to its anonymous inner class \$\endgroup\$
    – comodoro
    Commented Nov 29, 2018 at 20:49

1 Answer 1


If you could keep a reference to the VerticalGroup when you add it then you could simply call remove on that Actor to remove it from its parent.

If for some reason you can't get a reference to the node when it's either created or added to the Stage Actor tree then you can traverse the actors using some sort of path to find the one you want to delete. For example; if you know that the "path" to the Actor that you want to remove is always


then you can use a helper class like this one;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.Array;

public class StageHand {

    public static void removeByPath(Stage stage, Class...classes) {
        removeByPath(stage, new Array<Class>(classes));

    public static void removeByPath(Stage stage, Array<Class> classes) {
        for(Actor actor : stage.getActors())
            removeByPath(actor, 0, classes);

    private static void removeByPath(Actor actor, int index, Array<Class> classes) {
        Class<?> target = classes.get(index);
        if (actor.getClass().equals(target))
            if (index == classes.size - 1)
            else {
                if (actor instanceof Group) {
                    for(Actor child : ((Group)actor).getChildren())
                        removeByPath(child, index + 1, classes);

And you'd call it something like this

StageHand.removeByPath(stage, VisTable.class, VisScrollPane.class, VisTable.class, VerticalGroup.class);

If you need to delete based on some other criteria (like Actor's getName method for instance), then that would be trivial to achieve as well.

  • \$\begingroup\$ I updated the question. \$\endgroup\$ Commented Feb 1, 2018 at 21:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .