• 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

Lines and Images not drawing

 
Greenhorn
Posts: 11
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello fellow Ranchers! I'm having a problem with my program where the graphics are not drawing. I'm probabily missing something and I have spent alot of time trying to figure it out and haven't been successful.
This is an exercise for college,  which the objective is to simulate a car race. I haven't worked on the racing part as I have a similar code from a previous exercise, so I've started with having the graphics but it isn't working.
I have 4 classes: Race (the GUI), Track, Car and Main. I will post them below as well as the window that I get.
Thank you very much and I hope you all are having a wonderful day.
Dillon Colt









 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

it isn't working.  


Please explain.

How are you trying to debug the code to see what it is doing?  Try adding some print statements so you can see what methods are being executed.
 
Dillon Colt
Greenhorn
Posts: 11
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:

it isn't working.  


Please explain.

How are you trying to debug the code to see what it is doing?  Try adding some print statements so you can see what methods are being executed.



I have no idea of how to debug it I've tried some stuff that didn't work. The problem is probabily in the track class but I have no idea what it is. That's why I posted it here
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have no idea of how to debug it  


Start by adding calls to the System.out.println("a unique message text here") method in all the important methods in the code that need to execute for the code to work.  The print out will show you which methods are being called and which methods are not being called.   Then look closely at the methods that are not being called to see what the problem is.  If you find there are methods not being called and can't figure out why they  are not being called, post the names of the methods here.

Please explain what you expect to see that is not being shown.
 
Dillon Colt
Greenhorn
Posts: 11
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:

I have no idea of how to debug it  


Start by adding calls to the System.out.println("a unique message text here") method in all the important methods in the code that need to execute for the code to work.  The print out will show you which methods are being called and which methods are not being called.   Then look closely at the methods that are not being called to see what the problem is.  If you find there are methods not being called and can't figure out why they  are not being called, post the names of the methods here.

Please explain what you expect to see that is not being shown.



Well it is solved. Turns out I was using paintComponents() but should be using paintComponent(). Thank you for your help!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic