I am trying to use or add a JButton in a particular column but I am not extending the AbtractTableModel , so unable to use the JButton in JTable. In the code given , I am trying to make the 2nd column of the JTable as JButton.class and want to add JButton over there , but I am unable to proceed .
1. Don't have to put a JButton instance into the TableModel. TableModel contains data, JButton is a way to display something or a way to take input from the user, has nothing to do with the model.
2. You use table.getDefaultCellRenderer(JButton.class), but there is no default cell renderer for JButton.class, so it uses the String cell renderer in place.
For that thing to work you should create a class which implements TableCellRenderer, implement all the required methods and pass an instance of that class to setCellRenderer
Everywhere I am getting the example with extending AbstractTableModel , but I am not using that here so unable to find out how to use getClass method .so can you please post the class and the functions need to be implemented here so the posted example can be worked out.