Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i cant setText to JLabel

 
Lesole Mphinyane
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
somebody help out..

look at ma code..

i get the following errors...;

cars.java:54: non-static variable model cannot be referenced from a static context
model.setText(modelstr);
^
cars.java:55: non-static variable carMake cannot be referenced from a static context
carMake.setText(make);
^
 
Rob Camick
Ranch Hand
Posts: 2564
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all learn standard Java naming conventions. Every text book or tutorial I've ever seen uses them, so don't make up your own. Class names should start with an upper case.

The variable belong to the "Car" class, not the static method. Move the DB code to the class and out of the main() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic