I'm following some tutorial to create my own Inventory for my game. I have met with an insidious problem:

public class InventoryActor extends Window {
    public InventoryActor(Inventory inventory, DragAndDrop dragAndDrop, Skin skin) {
        super("Inventory", skin);

        // add an "X" button to the top right of the window, and make it hide the inventory
        TextButton closeButton = new TextButton("X", skin);
        closeButton.addListener(new HidingClickListener(this));

        // basic layout
        setPosition(400, 100);

Everything in this code is neat and nice. There's one BUT -


This method isn't implemented anywhere. Tutorial I'm following comes from 2014. Therefore I assume that it may be some deprecated/old method from Window class or something like that. My question is - is there any way I could repair it, and how can I add this 'X' close button to the window then? Should I use some other method? Regards and thanks in advance!


1 Answer 1


You're extending from the wrong class; extend from Dialog instead of Window. Dialog is a subclass of Window with much more functionality.

Dialog also has a few convenience methods such as Dialog button(String text) and Dialog text(String text) that automatically separates text and buttons appropriately and makes creating simple popups really easy.

The entire documentation can be found here.

  • \$\begingroup\$ Indeed! I've missed a fact that Dialog inherits from Window and was trying to do something with Table, unnecessarily. Now everything works properly. Thank you! :) \$\endgroup\$
    – spectral
    Commented Sep 6, 2018 at 18:18

You must log in to answer this question.

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