| Author |
jTable cannot find symbol method delRow(int)
|
Albert Robert
Greenhorn
Joined: Dec 02, 2011
Posts: 4
|
|
DefaultTableModel jTable1_d_t_model = (DefaultTableModel) jTable1.getModel();
line 2 error jTable1_d_t_model.delRow(row);
cannot find symbol
symbol: method delRow(int)
location: variable jTable1_d_t_model of type javax.swing.table.DefaultTableModel
see all my java method
but not delRow(int)
customise code for jTable1 in NetBeans
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3865
|
|
You're trying to call delRow() on a reference of type DefaultTableModel. But that doesn't exist in DefaultTableModel, it only exists in the anonymous class you've created.
You be able to use your method, you need to:
- Change from an anonymous class to a named one
- Cast the model to your model type, rather than DefaultTableModel
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1808
|
|
Why are you even doing this? DefaultTableModel already supports addRow(...) and removeRow(...) methods. There is no need to override all those methods.
If for some reason you do need a custom TableModel, then you should be extending AbstractTableModel.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
Matthew Brown wrote:You're trying to call delRow() on a reference of type DefaultTableModel. But that doesn't exist in DefaultTableModel, it only exists in the anonymous class you've created.
You be able to use your method, you need to:
- Change from an anonymous class to a named one
- Cast the model to your model type, rather than DefaultTableModel
Or simply override the removeRow(int) which DefaultTableModel already provides.
(That covers the Java programming aspect of the answer; however the practical aspect is covered by Rob Camick's answer.)
|
 |
Albert Robert
Greenhorn
Joined: Dec 02, 2011
Posts: 4
|
|
thanks a lot
Robert
Paul Clapham wrote:
Matthew Brown wrote:You're trying to call delRow() on a reference of type DefaultTableModel. But that doesn't exist in DefaultTableModel, it only exists in the anonymous class you've created.
You be able to use your method, you need to:
- Change from an anonymous class to a named one
- Cast the model to your model type, rather than DefaultTableModel
Or simply override the removeRow(int) which DefaultTableModel already provides.
(That covers the Java programming aspect of the answer; however the practical aspect is covered by Rob Camick's answer.)
|
 |
 |
|
|
subject: jTable cannot find symbol method delRow(int)
|
|
|