Package net.storm.api.ui
Class TableComponent
java.lang.Object
net.storm.api.ui.TableComponent
- All Implemented Interfaces:
net.runelite.client.ui.overlay.components.LayoutableRenderableEntity,net.runelite.client.ui.overlay.RenderableEntity
public class TableComponent
extends Object
implements net.runelite.client.ui.overlay.components.LayoutableRenderableEntity
A renderable table component for displaying tabular data in overlays.
This component supports multiple columns and rows with configurable alignment,
colors, and automatic text wrapping. It implements LayoutableRenderableEntity
for use within RuneLite's overlay system.
Features:
- Automatic column width calculation based on content
- Word wrapping for long text content
- Configurable alignment (left, center, right) per cell, row, column, or table
- Configurable colors per cell, row, column, or table
- Priority cascade: cell settings override row, row overrides column, column overrides table defaults
Example usage:
TableComponent table = new TableComponent();
table.setColumns("Name", "Value", "Status");
table.addRow("Item 1", "100", "Active");
table.addRow("Item 2", "200", "Inactive");
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumns(TableElement... columns) Adds multiple column headers as TableElement objects.voidAdds a row with the specified cell contents as strings.voidAdds multiple pre-built TableRow objects to the table.booleanisEmpty()Checks if the table has no data to display.render(Graphics2D graphics) Renders the table to the provided graphics context.voidsetColumnAlignments(TableAlignment... alignments) Sets alignments for multiple columns at once.voidsetColumns(String... columns) Replaces all existing columns with new column headers from strings.voidsetColumns(TableElement... elements) Replaces all existing columns with new TableElement column headers.voidReplaces all existing rows with new rows from string arrays.voidReplaces all existing rows with new TableRow objects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.runelite.client.ui.overlay.components.LayoutableRenderableEntity
getBounds, setPreferredLocation, setPreferredSize
-
Constructor Details
-
TableComponent
public TableComponent()
-
-
Method Details
-
render
Renders the table to the provided graphics context.- Specified by:
renderin interfacenet.runelite.client.ui.overlay.RenderableEntity- Parameters:
graphics- the graphics context to render to- Returns:
- the dimensions of the rendered table
-
isEmpty
public boolean isEmpty()Checks if the table has no data to display.- Returns:
trueif the table has no columns or no rows
-
setColumnAlignments
Sets alignments for multiple columns at once.- Parameters:
alignments- the alignments to apply, one per column
-
addRow
Adds a row with the specified cell contents as strings. Each string is converted to aTableElement.- Parameters:
cells- the cell contents for the row
-
addRows
Adds multiple pre-built TableRow objects to the table.- Parameters:
rows- the rows to add
-
setRows
Replaces all existing rows with new rows from string arrays.- Parameters:
elements- the new rows, each array representing a row's cell contents
-
setRows
Replaces all existing rows with new TableRow objects.- Parameters:
elements- the new rows
-
addColumns
Adds multiple column headers as TableElement objects.- Parameters:
columns- the column headers to add
-
setColumns
Replaces all existing columns with new TableElement column headers.- Parameters:
elements- the new column headers
-
setColumns
Replaces all existing columns with new column headers from strings.- Parameters:
columns- the new column header texts
-