I've made a class that extends JTable
class. I'm unable to call a public
method that is not defined in JTable
class. How can I do that?
Here is the code of my class:
public class CustomJTable extends JTable
{
private int id_mod = -1;
private ModelloCampiLista mcl = ModelloCampiLista.getInstance();
private TreeMap<Integer, DefaultCellEditor> tm_cbox = new TreeMap<>();
private Map<String,ModelloCampi> tm;
public CustomJTable(MyDefaultTableModel dtm)
{
super();
setCustomModel(dtm);
}
public void setCustomModel(MyDefaultTableModel dtm)
{
super.setModel(dtm);
update(dtm);
}
private void update(MyDefaultTableModel dtm)
{
id_mod = dtm.id_modello;
tm = dtm.tm;
composeTm_cbox();
}
private void composeTm_cbox()
{
TreeMap<Integer, ArrayList<String>> temp = mcl.getCBoxElements(id_mod);
for (Map.Entry<Integer, ArrayList<String>> entry : temp.entrySet())
{
int map_key = entry.getKey();
ArrayList<String> map_value = entry.getValue();
String[] temp_jcb_el = new String[map_value.size()];
for (int i = 0; i < map_value.size(); i++)
temp_jcb_el[i] = map_value.get(i);
JComboBox tmp_cbox = new JComboBox(temp_jcb_el);
DefaultCellEditor temp_dce = new DefaultCellEditor(tmp_cbox);
tm_cbox.put(map_key, temp_dce);
}
}
@Override
public TableCellEditor getCellEditor(int row, int column)
{
if (column == 1)
{
if (tm_cbox.getOrDefault(row, null) == null)
return super.getCellEditor(row, column);
return tm_cbox.get(row);
}
return super.getCellEditor(row, column);
}
}
I want to call the public method named setCustomModel
but I can't see it.