aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes  jTable cannot find symbol method delRow(int) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark " jTable cannot find symbol method delRow(int)" Watch " jTable cannot find symbol method delRow(int)" New topic
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: 4466
    
    8

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: 2215
    
    7
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: 18907
    
    8

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.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jTable cannot find symbol method delRow(int)