Display a static table.

Method Signatures and Parameters

Jt.table(List<E> rows)

rows (List<E>)

The list of objects representing table rows

Jt.table(Object dataframe)

dataframe (Object)

A tablesaw Table instance. tablesaw is an optional dependency, so this method is not typed.

Jt.table(E[] rows)

rows (E[])

The array of objects representing table rows

Jt.tableFromArrayColumns(Map<String, E[]> cols)

cols (Map<String, E[]>)

A map where keys are column names and values are arrays of column data

Jt.tableFromListColumns(Map<String, Values> cols)

cols (Map<String, Values>)

A map where keys are column names and values are collections of column data

Chainable builder methods

key(String key)

A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key.

No description

use()

Put the widget in the app, in the MAIN container.

use(JtContainer container)

Put the widget in the app, in the provided container.

Examples

Basic table with data objects

 import tech.catheu.jeamlit.core.Jt;

 import java.util.List;

 public class TableApp {
     public static void main(String[] args) {
         record Person(String name, int age, String city) {
         }

         List<Object> data = List.of(new Person("Alice", 25, "New York"),
                                     new Person("Bob", 30, "San Francisco"),
                                     new Person("Charlie", 35, "Chicago"));

         Jt.table(data).use();
     }
 }

Basic table with array of objects

 import io.jeamlit.core.Jt;

 public class TableArrayApp {
     public static void main(String[] args) {
         record Product(String name, double price, boolean inStock) {}

         Product[] products = {
             new Product("Laptop", 999.99, true),
             new Product("Mouse", 25.50, false),
             new Product("Keyboard", 75.00, true)
         };

         Jt.table(products).use();
     }
 }

Table from column arrays

 import io.jeamlit.core.Jt;

 import java.util.Map;

 public class TableColumnsArrayApp {
     public static void main(String[] args) {
         Map<String, Object[]> salesData = Map.of(
                 "Month", new String[]{"Jan", "Feb", "Mar", "Apr"},
                 "Sales", new Integer[]{1200, 1350, 1100, 1450},
                 "Target", new Integer[]{1000, 1300, 1200, 1400},
                 "Achieved", new Boolean[]{true, true, false, true}
         );

         Jt.tableFromArrayColumns(salesData).use();
     }
 }

Table from column lists

 import io.jeamlit.core.Jt;

 import java.util.List;
 import java.util.Map;

 public class TableColumnsListApp {
     public static void main(String[] args) {
         Map<String, List<Object>> employeeData = Map.of(
                 "Name", List.of("Alice", "Bob", "Charlie", "Diana"),
                 "Department", List.of("Engineering", "Sales", "Marketing", "Engineering"),
                 "Salary", List.of(95000, 75000, 68000, 102000),
                 "Remote", List.of(true, false, true, true)
         );

         Jt.tableFromListColumns(employeeData).use();
     }
 }

forum

Still have questions?

Go to our discussions forum for helpful information and advice from Jeamlit experts.