I'm trying to make a window, then use the pack method to get the right size, but the window maximizes instead. Here's my code:

private Table buildOptionsWindowLayer() {
    winOptions = new Window("Options", skinLibgdx);
    // (...) building some widgets

    Gdx.app.log(TAG, "pref width is " + winOptions.getPrefWidth());
    // displays: "pref width is 247.0"


    // move the window
    winOptions.setPosition(Constants.VIEWPORT_GUI_HEIGHT - winOptions.getWidth() - 50, 50);
    return winOptions;

The window ends up with a width of 800.0f. Why?

What it is supposed to render: enter image description here

What it does render: enter image description here

  • \$\begingroup\$ Did you ever get this working? Have the same issue where I expect pack() to wrap my window around my widgets, but the window stays maximised by default. (Sorry, unable to add a comment due to just signing up) \$\endgroup\$
    – Nelson
    Nov 11, 2017 at 16:08


You must log in to answer this question.

Browse other questions tagged .