Class Table
java.lang.Object
com.codename1.cli.Table
Rows and columns rendered as text, aligned by the columns each cell takes on a terminal, so styled cells, wide characters and emoji line up:
Table table = new Table("Name", "Status", "Size")
.align(2, Table.Align.RIGHT);
table.addRow("api", Console.style("running", Console.Style.GREEN), "12 MB");
table.addRow("worker", Console.style("stopped", Console.Style.RED), "3 MB");
Console.print(table.render());
A table wider than maxWidth (the terminal by default) shrinks its widest
columns and wraps their cells. A cell may hold line breaks.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow a column's cells line up.static enumThe lines drawn around and between cells. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends a row.align(int column, Table.Align align) Aligns columncolumn(from 0).border(Table.Border border) The border style;Table.Border.ROUNDEDby default,Table.Border.ASCIIwhenConsole.unicode()says box drawing is unsafe.headerStyle(boolean bold) Whether the header row is bold (when color is on); true by default.maxWidth(int maxWidth) The widest the table may be, in columns; the terminal width by default.render()The table as text, every line ended by a line break.introwCount()The number of rows added so far, header excluded.toString()Returns a string representation of the object.
-
Constructor Details
-
Table
A table with these column headers; none for a table without a header row, whose column count then comes from its widest row.
-
-
Method Details
-
align
Aligns columncolumn(from 0). -
border
The border style;Table.Border.ROUNDEDby default,Table.Border.ASCIIwhenConsole.unicode()says box drawing is unsafe. -
maxWidth
The widest the table may be, in columns; the terminal width by default. -
headerStyle
Whether the header row is bold (when color is on); true by default. -
addRow
-
rowCount
public int rowCount()The number of rows added so far, header excluded. -
render
The table as text, every line ended by a line break. -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-