Answer the question
In order to leave comments, you need to log in
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);
TextArea
in mainGuiGroup
displays the text without problems. group
do not display. And if you area
transfer it to that ill-fated group, then the rendering of the text in it will also break. 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 questionAsk a Question
731 491 924 answers to any question