V
V
vladocc2018-01-07 08:29:26
Java
vladocc, 2018-01-07 08:29:26

Why in libgdx does TextArea display text in one container and not in another?

There is this code

TextureAtlas atlas = new TextureAtlas("buttons.pack");
        Skin skin = new Skin(atlas);
        TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
        Drawable up = skin.getDrawable("button_off");
        Drawable down = skin.getDrawable("button_on");
        style.up = up;
        style.down = down;
        style.font = LevelManager.mainFont;
        VerticalGroup leftGroup = new VerticalGroup();
        button = new TextButton("Start", style);
        button.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                play();
            }
        });
        button.setHeight(h / 21);
        Table tableStart = new Table();
        tableStart.add(button).height(button.getHeight());
        leftGroup.addActor(tableStart);
        Table tableReset = new Table();
        leftGroup.addActor(tableReset);
        leftGroup.center();
        //button.pack();

        VerticalGroup middleGroup = new VerticalGroup();
        TextField.TextFieldStyle textStyle = new TextField.TextFieldStyle();
        textStyle.font = LevelManager.mainFont;
        textStyle.fontColor = Color.WHITE;
        final TextArea area = new TextArea("1.0", textStyle);
        TextureRegionDrawable regionDrawable = new TextureRegionDrawable(new TextureRegion(checkboxFalseTexture));
        regionDrawable.setMinHeight(h/32);
        regionDrawable.setMinWidth(h / 32);
        TextureRegionDrawable regionDrawable1 = new TextureRegionDrawable(new TextureRegion(checkboxTrueTexture));
        regionDrawable1.setMinHeight(h/32);
        regionDrawable1.setMinWidth(h/32);
        CheckBox.CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle(regionDrawable, regionDrawable1, LevelManager.mainFont, Color.WHITE);
        final CheckBox checkBox = new CheckBox("Encrypter", checkBoxStyle);
        checkBox.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
        }
        });
        Table table = new Table();
        table.add(area).height(h / 36).center();
        //table.center();
        table.pack();
        Table checkboxTable = new Table();
        checkboxTable.add(checkBox).padTop(h/42);
        checkboxTable.pack();
        middleGroup.addActor(table);
        middleGroup.addActor(checkboxTable);

        mainGuiGroup.addActor(leftGroup);
        mainGuiGroup.addActor(middleGroup);

        System.out.println(mainGuiGroup.getWidth() + " " + mainGuiGroup.getHeight());

        //actionLabel.debug();

        VerticalGroup group = new VerticalGroup();
        group.center();
        final TextArea pathArea = new TextArea("pattern.room", textStyle);
        final TextArea widthArea = new TextArea("" + 8, textStyle);
        final TextArea heightArea = new TextArea("" + 8, textStyle);
        Button button = new TextButton("Create", style);

        button.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                String path = pathArea.getText();
                int width = Integer.parseInt(widthArea.getText());
                int height = Integer.parseInt(heightArea.getText());
                ((Game) Gdx.app.getApplicationListener()).setScreen(new MainScreen(path, width, height));
            }
        });

        //group.addActor(area);
        group.addActor(pathArea);
        group.addActor(widthArea);
        group.addActor(heightArea);
        group.addActor(button);
        group.setFillParent(true);

        stage = new Stage();
        stage.addActor(mainGuiGroup);
        stage.addActor(group);

And TextAreain mainGuiGroupdisplays the text without problems.
And those that groupdo not display. And if you areatransfer it to that ill-fated group, then the rendering of the text in it will also break.
Why is this happening? Already tried to shove both the group and the table into this place. It still doesn't render text.
But on the button the text appears without problems.
And getText()for all fields it returns what was written in their constructors.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question