Hi
I had the need for table control, something missing from Tonegodgui. So, here is my attempt. It is loosly based off of SelectList, but using Elements for each row/cell, not a scrollable text area. For this reason it’s probably not best for large tables, but it will suffice for my needs for now, and hopefully others.
Usage is …
[java]
final Table table = new Table(screen, new Vector2f(10, 40)) {
@Override
public void onChange() {
}
};
table.setColumnResizeMode(Table.ColumnResizeMode.AUTO_FIRST);
table.addColumn(“Column 1”);
table.addColumn(“Column 2”);
table.addColumn(“Column 3”);
for (int i = 0; i < 20; i++) {
Table.TableRow row = new Table.TableRow(screen, table);
row.addCell(String.format(“Row %d, Cell 1”, i), i);
row.addCell(String.format(“Row %d, Cell 2”, i), i);
row.addCell(String.format(“Row %d, Cell 3”, i), i);
table.addRow(row);
}
panel.addChild(table);
[/java]
- You can stuff Object values into each cell. If these implements Comparable, they are used for sorting when the headers are clicked.
- There is currently no facility for single cell selection, but it should be relatively easy to add.
- 4 column resize modes.
- You’ll see diagonal resize cursors when hovering over the buttons. I think this is a bug, they should not be shown if the element is not resizable north/south.
Patch is here.
And a video …
[video]http://www.youtube.com/watch?v=2c5QggEBqD0&feature=youtu.be[/video]
Hope you find it useful.
RR