Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Lines and Images not drawing  RSS feed

 
Dillon Colt
Greenhorn
Posts: 11
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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









 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • 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
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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: 1733
22
  • Mark post as helpful
  • send pies
  • 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
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!