I want to add a JTable to a JFrame to pure code without the NetBeans Desing tool
I want to add a JTable to a JFrame to pure code without the NetBeans Desing tool
The easiest way is by following these steps:
Object
for the value shown in the header of columnas
2D
of type Object
for the values to be displayed in the JTable
JTable
by passing the two Arrangements created previously per parameter to the constructor You add it to JFrame
u Other contenedor
Object[] nombrecolumnas = {"Nombre", "Apellido", "Edad"};
Object[][] datos ={{"Nombre1", "Apellido1", 22},{"Nombre2", "Apellido2", 4}};
tabla = new JTable(datos,nombrecolumnas);
Jframe.add(tabla);