Im using Window Builder plugin in eclipse to make all the visual components, and i add a JTable, and at first it was a simple JTable, and it show the data correctly. Since i need that the data of the JTable be non-editable, i create a model to use the method isCellEditable. my code is this.
public class MyTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
private String[] columnNames;
private Object[][] data;
public MyTableModel(Object[][] sentdata, String[] cnames){
columnNames = cnames;
data = sentdata;
}
@Override
public int getColumnCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getRowCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
// TODO Auto-generated method stub
return null;
}
public boolean isCellEditable (int row, int column){
return false;
}
}//fin del modelo
and in the constructor of the class is this
String[] NombresdeColumnas = {"Nombre del Producto", "Cantidad en Inventario", "Precio Unitario"};
RegistroInventario inventariodatos = new RegistroInventario();
Object[][] data = inventariodatos.regresarInventario();
MyTableModel model1 = new MyTableModel(data, NombresdeColumnas);
Table_Inventario = new JTable(model1);
Table_Inventario.setGridColor(Color.gray);
JScrollPane scrollPane_1 = new JScrollPane();
scrollPane_1.setViewportView(Table_Inventario);
and it doesnt show anything, but when i was doing this:
Table_Inventario = new JTable(data, NombresdeColumnas);
it was working just fine, i don´t know if the error has todo with de Window Builder form eclipse or in the code cause im new doning JTables.