Need Help with this err non-static method getRowCount() cannot be referenced from a static context
Joined: Apr 09, 2009
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.
Rahul P Kumar
Joined: Sep 26, 2009
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.
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.