# LibGDX : Scene2D ScrollPane

I want to create a list of buttons with ScrollPane , but I cant create a ScrollPane . In the constructor method in the examples Skins are used (.atlas , .json files) but how to create these files?

Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));


Is there a program to generate this json ? As I noticed a lot of Scene2D elements need skins.

## 2 Answers

Unfortunately, you usually have to write these json files by hand. The syntax isn't too awful. To style an object its usually

<fullyQualifiedUIWidgetName>\$<StyleClassName>:{
<styleName>: {
<styleParameter>: <value>,
<styleParameter>: <value>,
},
<styleName>: {
<styleParameter>: <value>,
<styleParameter>: <value>,
},
...
}


The libgdx test project has an example ui skin that I usually use to start from (just make sure that you copy the uiskin.atlas and uiskin.png files from the same directory to make it work)

Here is a pretty good article on using libgdx skins

Libgdx does, however, come with an atlas file generator called TexturePacker to help create your .atlas files from your image assets. You have to have inlcuded the tools library when you created your project.

It will take several different images and combine them into one or more pngs, then give you an atlas file. As long as this png and atlas file are in the same directory as the json file with the same name, then the skin will automatically load them

TexturePacker is a command line tool so I usually create another project to manage it. Here is a blog post I wrote on how to do that.

you can create scrollPane without that. Create it with no input and then call setWidget(Table or Actor) on it to attach the widget you want