AbstractTableModel
is an abstract implementation that serves as a basis for creating a "modeling" of data in a JTable
, has no relation to combos.
To model data in JComboBoxes, you can use the class DefaultComboBoxModel
, which is also an implementation of data modeling, however it is concrete and generally meets most needs when using combos, especially when it will be filled with primitive types and strings.
If you need something more specific than this implementation does not solve, you need to create your own implementation, or overwrite method implementation toString()
of the class that will represent the object that will populate the combo, depends on the complexity of what you want to do.
The links below have some implementation examples:
I usually use a generic implementation I created, so I do not need to implement a template for each type of object I create that will populate a combo, but for it to function properly, its bean need to have method toString()
overwritten. In this link there is an example implementation of it.
By reading the question, I think that the question can also be related to how to add a combo to the editor of some cell / column in a table, and for that, you will not use models, since it is not a change of the fill model , but rather from displaying table cells through the TableCellRenderer
, which contains the methods you need to create a custom way to render cells, and the TableCellEditor
", which contains the methods needed to create a custom way to render the cell when it enters edit mode. If you'd like to read more about it, I recommend the official documentation tutorials: How to Use Tables and How to Use Combo Boxes a>.