APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class Table

extends WidgetGroup
Class Inheritance
Known Direct Subclasses
com.badlogic.gdx.scenes.scene2d.ui.Window, com.badlogic.gdx.scenes.scene2d.ui.Button
Imports
java.util.Arrays, com.badlogic.gdx.graphics.Color, com.badlogic.gdx.graphics.g2d.Batch, com.badlogic.gdx.graphics.glutils.ShapeRenderer, .ShapeRenderer.ShapeType, com.badlogic.gdx.math.Rectangle, com.badlogic.gdx.scenes.scene2d.Actor, .Touchable, com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle, .Value.Fixed, com.badlogic.gdx.scenes.scene2d.utils.Drawable, .Layout, com.badlogic.gdx.utils.Align, .Array, .DefaultPool, .Null, .Pool

A group that sizes and positions children using table constraints.

Children added with add(Actor...) (and similar methods returning a Cell) are laid out in rows and columns. Other children may be added with addActor(Actor) (and similar methods) but are not laid out automatically and don't affect the preferred or minimum sizes.

By default, getTouchable() is Touchable#childrenOnly.

The preferred and minimum sizes are that of the children laid out in columns and rows.

Author
Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static class

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv Drawable
public static Value
backgroundBottom

Value that is the bottom padding of the table's background.

public static Value
backgroundLeft

Value that is the left padding of the table's background.

public static Value
backgroundRight

Value that is the right padding of the table's background.

public static Value
backgroundTop

Value that is the top padding of the table's background.

private final Cell<T extends Actor>
pack-priv static final Pool<Cell<T extends Actor>>
private final Array<Cell<T extends Actor>>
private boolean
private final Array<Cell<T extends Actor>>
private float[]
private float[]
private int
private static float[]
private float[]
pack-priv Table.Debug
public static Color
public static Color
pack-priv Array<Table.DebugRect>
public static Color
private float[]
private float[]
private boolean
pack-priv Value
pack-priv Value
pack-priv Value
pack-priv Value
pack-priv boolean
private Cell<T extends Actor>
private float[]
private float[]
private float[]
private int
private static float[]
private boolean
private Skin
private float
private float
private float
private float

Constructor Summary

AccessConstructor and Description
public
public
Table(Skin skin)

Creates a table with a skin, which is required to use add(CharSequence) or add(CharSequence, String).

Method Summary

Modifier and TypeMethod and Description
public <T extends Actor> Cell<T>
add(T actor)

Adds a new cell to the table with the specified actor.

public Table
add(Actor... actors)

public Cell<Label>
add(CharSequence text)

Adds a new cell with a label.

public Cell<Label>
add(CharSequence text, String labelStyleName)

Adds a new cell with a label.

public Cell<Label>
add(CharSequence text, String fontName, Color color)

Adds a new cell with a label.

public Cell<Label>
add(CharSequence text, String fontName, String colorName)

Adds a new cell with a label.

public Cell<T extends Actor>
add()

Adds a cell without an actor.

private void
addDebugRect(float x, float y, float w, float h, Color color)

private void
addDebugRects(float currentX, float currentY, float width, float height)

public Table
align(int align)

Alignment of the logical table within the table actor.

public Table
background(Drawable background)

public Table
background(String drawableName)

public Table
bottom()

Adds Align#bottom and clears Align#top for the alignment of the logical table within the table actor.

public Table
center()

Sets the alignment of the logical table within the table actor to Align#center.

public void
clearChildren(boolean unfocus)

Overrides com.badlogic.gdx.scenes.scene2d.Group.clearChildren.

Removes all actors and cells from the table.

private void
public Table
clip()

Sets setClip(boolean) to true.

public Table
clip(boolean enabled)

public Cell<T extends Actor>
columnDefaults(int column)

Gets the cell values that will be used as the defaults for all cells in the specified column.

private void
public Table
public Table
debug(Table.Debug debug)

Turns debug lines on or off.

public Table
debugActor()

Turns on actor debug lines.

public Table
public Table
debugCell()

Turns on cell debug lines.

public Table
debugTable()

Turns on table debug lines.

public Cell<T extends Actor>
defaults()

The cell values that will be used as the defaults for all cells.

public void
draw(Batch batch, float parentAlpha)

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.draw.

If this method is overridden, the super method or validate() should be called to ensure the widget group is laid out.

protected void
drawBackground(Batch batch, float parentAlpha, float x, float y)

Called to draw the background, before clipping is applied (if enabled).

public void
drawDebug(ShapeRenderer shapes)

Overrides com.badlogic.gdx.scenes.scene2d.Group.drawDebug.

Draws this actor's debug lines if getDebug() is true and, regardless of getDebug(), calls Actor#drawDebug(ShapeRenderer) on each child.

protected void
drawDebugBounds(ShapeRenderer shapes)

Overrides com.badlogic.gdx.scenes.scene2d.Actor.drawDebugBounds.

Draws a rectangle for the bounds of this actor if getDebug() is true.

private void
private void
private float[]
ensureSize(float[] array, int size)

public int
public Drawable
public <T extends Actor> Cell<T>
getCell(T actor)

Returns the cell for the specified actor in this table, or null.

public Array<Cell<T extends Actor>>
getCells()

Returns the cells for this table.

public boolean
public float
getColumnMinWidth(int columnIndex)

Returns the min width of the specified column.

public float
getColumnPrefWidth(int columnIndex)

Returns the pref width of the specified column.

public int
public float
getColumnWidth(int columnIndex)

Returns the width of the specified column, or 0 if the table layout has not been validated.

public float
public float
public float
public Value
public float
public Value
public float
public Value
public float
public Value
public float
public float
public float
public float
public int
getRow(float
The y coordinate, where 0 is the top of the table.
y
)

Returns the row index for the y coordinate, or -1 if not over a row.

public float
getRowHeight(int rowIndex)

Returns the height of the specified row, or 0 if the table layout has not been validated.

public float
getRowMinHeight(int rowIndex)

Returns the min height of the specified row.

public float
getRowPrefHeight(int rowIndex)

Returns the pref height of the specified row.

public int
public Skin
getSkin()

Returns: The skin that was passed to this table in its constructor, or null if none was given.

public Table.Debug
public Actor
hit(float x, float y, boolean touchable)

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.hit.

If this method is overridden, the super method or validate() should be called to ensure the widget group is laid out.

public void
invalidate()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.invalidate.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.invalidate.

Invalidates this actor's layout, causing layout() to happen the next time validate() is called.

public void
layout()

Overrides com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.layout.

Implements com.badlogic.gdx.scenes.scene2d.utils.Layout.layout.

Positions and sizes children of the table using the cell associated with each child.

public Table
left()

Adds Align#left and clears Align#right for the alignment of the logical table within the table actor.

private Cell<T extends Actor>
public Table
pad(Value pad)

Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.

public Table
pad(Value top, Value left, Value bottom, Value right)

public Table
pad(float pad)

Sets the padTop, padLeft, padBottom, and padRight around the table to the specified value.

public Table
pad(float top, float left, float bottom, float right)

public Table
padBottom(Value padBottom)

Padding at the bottom edge of the table.

public Table
padBottom(float padBottom)

Padding at the bottom edge of the table.

public Table
padLeft(Value padLeft)

Padding at the left edge of the table.

public Table
padLeft(float padLeft)

Padding at the left edge of the table.

public Table
padRight(Value padRight)

Padding at the right edge of the table.

public Table
padRight(float padRight)

Padding at the right edge of the table.

public Table
padTop(Value padTop)

Padding at the top edge of the table.

public Table
padTop(float padTop)

Padding at the top edge of the table.

public boolean
removeActor(Actor actor)

Overrides com.badlogic.gdx.scenes.scene2d.Group.removeActor.

Removes an actor from this group and unfocuses it.

public boolean
removeActor(Actor actor, boolean unfocus)

Overrides com.badlogic.gdx.scenes.scene2d.Group.removeActor.

Removes an actor from this group.

public Actor
removeActorAt(int index, boolean unfocus)

Overrides com.badlogic.gdx.scenes.scene2d.Group.removeActorAt.

Removes an actor from this group.

public void
reset()

Removes all actors and cells from the table (same as clearChildren()) and additionally resets all table properties and cell, column, and row defaults.

public Table
right()

Adds Align#right and clears Align#left for the alignment of the logical table within the table actor.

public Cell<T extends Actor>
row()

Indicates that subsequent cells should be added to a new row and returns the cell values that will be used as the defaults for all cells in the new row.

public void
setBackground(String drawableName)

Sets the background drawable from the skin and adjusts the table's padding to match the background.

public void
setBackground(Drawable
May be null to clear the background.
background
)

public void
setClip(boolean enabled)

Causes the contents to be clipped if they exceed the table's bounds.

public void
setDebug(boolean enabled)

Overrides com.badlogic.gdx.scenes.scene2d.Actor.setDebug.

If true, drawDebug(ShapeRenderer) will be called for this actor.

public void
setRound(boolean round)

If true (the default), positions and sizes of child actors are rounded and ceiled to the nearest integer value.

public void
setSkin(Skin skin)

public Cell<Stack>
stack(Actor...
May be null or empty to add a stack without any actors.
actors
)

Adds a new cell to the table with the specified actors in a Stack.

public Table
top()

Adds Align#top and clears Align#bottom for the alignment of the logical table within the table actor.

Inherited from com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup:
childrenChangedgetMaxHeightgetMaxWidthinvalidateHierarchyneedsLayoutpacksetFillParentsetLayoutEnabledsizeChangedvalidate