TableComponent
A sortable data table with a sticky header.
Java
Inside a PanelComponent constructor. The same call draws in every family and chroma.
Java
TableComponent<Pet> pets = add(new TableComponent<Pet>(at(new Box("pets", 8, 8, 280, 120)), 14)
.column("Name", c -> c.text(Pet::name).weight(2)
.comparator(Comparator.comparing(Pet::name, String.CASE_INSENSITIVE_ORDER)))
.column("Age", c -> c.text(p -> p.age() + " d").fixed(44).align(TableComponent.Align.RIGHT)
.comparator(Comparator.comparingInt(Pet::age)))
.column("Mood", c -> c.renderer((d, theme, pet, cell, hovered, selected) ->
d.fill(cell.x() + 3, cell.y() + 3, cell.right() - 3, cell.bottom() - 3, theme.palette().good())))
.emptyText(words.get("mymod.pets.none"))
.onSelect(this::show)
.onActivate(this::open));
pets.setItems(allPets);Rows
