Q:

LibGDX - Image width is not set to resetting to zero when full width

I am making a progress bar for showing the players current experience. However I have come around to a bug, which appears when the player is maxing out his experience and then is getting a new level. In the ideal world my code should reset the progress bar image width (which is a Scene2D image btw), but for some reason it is not setting the image width to zero, but is setting it to its full width instead, which I can't seem to understand why. I hope anyone can help me.
I have provided my code below, and also uploaded a video on youtube with my bug - Video of the bug
The method below is the one I use to change the experience progress bar width as well as the experience.
public void changeLevelExperience(int gainedExperience) {
    float maxExpDividedInPixels = 131f / this.GAME.gameScreen.getGameManager().maxExperience;

    this.GAME.gameScreen.getGameManager().currentExperience += gainedExperience;

    if (this.GAME.gameScreen.getGameManager().currentExperience >= this.GAME.gameScreen.getGameManager().maxExperience) {
        this.GAME.gameScreen.getGameManager().currentLevel++;
        this.currentLevelLabel.setText(this.GAME.gameScreen.getGameManager().currentLevel + "");
        //TODO: Another arrangement for the experience needs to be made.
        this.GAME.gameScreen.getGameManager().maxExperience += 35;
        this.GAME.gameScreen.getGameManager().currentExperience = 0;
        Gdx.app.debug(TAG, this.GAME.gameScreen.getGameManager().currentExperience + "");
    }

    this.levelProgressBar.setWidth((int) (maxExpDividedInPixels * this.GAME.gameScreen.getGameManager().currentExperience * this.scaleFactor));
}

A:

I haven't personally used ProgressBar yet, but it looks like the right way to set the current percentage is using setValue(float), not setWidth(float). I'd start with that.

Also, saving your GameManager object in a local variable instead of writing this.GAME.gameScreen.getGameManager() 10 times will make the code a lot more legible ;)

A:

I found the bug. It was with some help from people at a facebook group. :)
The bug occours, because my Scene2D Image (the level progress bar) was a child of a scene2D Table. And the Table was initially set to have a column width to the width of the image, when it was at its largest size. This width was now set to zero, as I have done in the code below.
table.add(this.levelProgressBar).width(0 * this.scaleFactor).height(10 * this.scaleFactor);

Apparently the Image width is reset to the tables column width,when it is set to the width of zero.
Thank you all which tried to help me. It was really appreciated :)

