libgdx 中的表格有问题

There's something wrong with tables in libgdx

public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
Stage stage;
@Override
public void create () {
    stage=new Stage();
    batch = new SpriteBatch();
    Image mg=new Image(new Texture("badlogic.jpg"));
    Table table=new Table();
    table.add();
    table.add(mg);
    table.add();
    stage.addActor(table);
}

@Override
public void render () {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    batch.end();
    stage.draw();
}

@Override
public void dispose () {
    batch.dispose();
}}

任何人都可以告诉我为什么我的图像没有显示或者这段代码有什么问题吗?它有效,但我看不到我的图像。

您需要指定图像的大小,也很可能您需要指定 table:

的位置和大小
Image mg=new Image(new Texture("badlogic.jpg"));
Table table = new Table();
table.setSize(...;
table.setPosition(...);
table.add();
table.add(mg).size(...);
table.add();
stage.addActor(table);