• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jTable cannot find symbol method delRow(int)

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 3324
32
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic