• 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

Need Help with this err non-static method getRowCount() cannot be referenced from a static context

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I created a GUI using the Netbeans framework. From that interface I have a JButton, and within the actionPerformed method of that button is the following code.
The main() method is in the same class.
I tried moving it ( main() )to another class, and calling setVisible() from there to fire up the interface, hoping to have some effect
on the 'static context'.

Obviously I don't fully understand what is going on here with the 'static context', and my question would be, in this case, what does it mean?
I know what a static member is, and what a static method does, at least fundamentally.
I have a general idea that main() is static because the run-time environment will be looking for it as specified by the Standard.

Hopefully my eyes have glazed over and I am missing something simple, and that another pair of eyes will quickly point out.
Otherwise, I'm need to brush up on whatever I don't know here.

I thought this to be a good minimalist starting point regarding the posting of code.

Thanks.

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getRowCount() is not static method means..it is not a class method, rather it is an instance method. Only class method can be invoked by Class.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To call a non-static method you need an instance of the class. In your case, you need an instance of CarrierTableModel (you know, new CarrierTableModel(...)). Either that, or make the method static (if possible).

This is really a beginner's question, so moving to Beginning Java.
 
reply
    Bookmark Topic Watch Topic
  • New Topic