How to create a LibGDX Dialog (example)

If you ever need to create a Dialog in LibGDX, I can confirm that this example code works:

Skin uiSkin = new Skin(Gdx.files.internal("default_skin/uiskin.json"));
Dialog dialog = new Dialog("Warning", uiSkin, "dialog") {
    public void result(Object obj) {
        System.out.println("result "+obj);
    }
};
dialog.text("Are you sure you want to yada yada?");
dialog.button("Yes", true); //sends "true" as the result
dialog.button("No", false); //sends "false" as the result
dialog.show(stage);

The hardest part of this for me was understanding the Skin part. To get this working, you basically just need to copy the files under the skin directory in this project into your project’s assets folder. To keep things organized, I put those four files under my assets/default_skin directory, to be more accurate. Note that in this example, the stage variable is an instance of Stage.

I found some convoluted LibGDX Dialog examples on the internet, but this one comes from this stackexchange URL. See that page for more information.