Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:11:44+00:00 2026-06-14T23:11:44+00:00

I am trying to create a Textbutton with a skin that is defined in

  • 0

I am trying to create a Textbutton with a skin that is defined in a json file.
I am a beginner at libgdx, so maybe the problem is between monitor and keyboard 😉
I hope you can help me.

LibGDX-version: Fresh Git-Pull (20th Nov. 2012)

My json (at “data/button.json”):

{
        resources: {
                com.badlogic.gdx.graphics.Color: {
                        white: { r: 1, g: 1, b: 1, a: 1 },
                        downFontColor: { r: 1, g: 0.1, b: 0.2, a: 1 }
                },
                com.badlogic.gdx.graphics.g2d.BitmapFont: {
                        default-font: { file: default.fnt }
                }
        },
        styles: {
                com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
                        default: {
                                font: default-font, 
                                downFontColor: downFontColor,
                                fontColor: white
                        }
                }
        }
 }  

Where it fails:

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

Exception:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.SerializationException: Error reading file: data/button.json
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: data/button.json
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:72)
    at eu.loecken.tools.virtuallampsi.screens.MenuScreen.createButton(MenuScreen.java:105)
    at eu.loecken.tools.virtuallampsi.screens.MenuScreen.create(MenuScreen.java:47)
    at eu.loecken.tools.virtuallampsi.screens.MenuScreen.show(MenuScreen.java:131)
    at com.badlogic.gdx.Game.setScreen(Game.java:62)
    at eu.loecken.tools.virtuallampsi.MainGame.create(MainGame.java:48)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:125)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: data/button.json
    at com.badlogic.gdx.utils.Json.fromJson(Json.java:596)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:93)
    ... 8 more
Caused by: com.badlogic.gdx.utils.SerializationException: 
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:424)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:1)
    at com.badlogic.gdx.utils.Json.readValue(Json.java:762)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:409)
    at com.badlogic.gdx.utils.Json.fromJson(Json.java:594)
    ... 9 more
Caused by: java.lang.ClassNotFoundException: resources
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:422)
    ... 13 more

*Working code without json-file: * (just to show that something works)

Texture texture = new Texture(Gdx.files.internal(imageURL));
textures.add(texture);

TextureRegion image = new TextureRegion(texture);
TextureRegion flippedImage = new TextureRegion(image);
flippedImage.flip(true, true);
ButtonStyle style = new ButtonStyle();
style.up = new TextureRegionDrawable(image);
style.down = new TextureRegionDrawable(flippedImage);
return new Button(style);

Update: Also this one is working:

private final BitmapFont defaultFont = new BitmapFont(
        Gdx.files.internal("data/default.fnt"), false);
private final Texture btnTexture = new Texture(
        Gdx.files.internal("buttons/lvl.png"));

private Button createButton(String text) {
    // Initialize skin
    // Skin skin = new Skin(Gdx.files.internal("data/button.json"));
    TextureRegion image = new TextureRegion(btnTexture);
    TextureRegion flippedImage = new TextureRegion(image);
    flippedImage.flip(true, true);
    TextButtonStyle style = new TextButtonStyle();
    style.up = new TextureRegionDrawable(image);
    style.down = new TextureRegionDrawable(flippedImage);
    style.font = defaultFont;
    return new TextButton(text, style);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:11:45+00:00Added an answer on June 14, 2026 at 11:11 pm

    this is how your json file should be like , according to Skin docs

    {
        className: {
                name: resource,
                ...
        },
        className: {
                name: resource,
                ...
        },
        ...
    }
    

    as you can see you get the exception since it looks for "resources" class ..
    so just change it to the template above for example:

    {
        com.badlogic.gdx.graphics.Color: {
                white: { r: 1, g: 1, b: 1, a: 1 },
                red: { r: 1, g: 0, b: 0, a: 1 },
                yellow: { r: 0.5, g: 0.5, b: 0, a: 1 },
        },
        com.badlogic.gdx.graphics.g2d.BitmapFont: {
                medium: { file: default.fnt }
        },
        com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
                default: {
                        down: button, up: button,
                        font: medium, fontColor: white
                },
                green: {
                        down: button, up: button,
                        font: medium, fontColor: { r: 0, g: 1, b: 0, a: 1 }
                }
        }
    

    }

    P.S button is an real image resource
    also i’m pretty sure your template of the skin json file is for old versions of libgdx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying create a small web application that allows a user to login
I'm trying create an immutable object and initialise it from xml config file in
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a simple plugin that simply connects to an ftp site, looks
I'm trying create a gui using Tkinter that grabs a username and password and
I'm trying create this function such that if any key besides any of the
I'm trying create a query that will output a total number, as well as
I'm trying create a regex that verifies an xml entity name is valid (see
I'm trying create an intermediate object to work with elsewhere that I can pass
I'm currently trying create a service that will return results of a OLAP cube

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.