Java repaint not updating


11-Oct-2019 00:21

It may be repaint(), as someone previously pointed out, but I'm not too sure on that.

I don't have much experience with the AWT or SWING toolkits, but I imagine something like this should work. Rather than looping through every button and checking to see if they need updated, you can probably just directly update the two buttons that need updating.

You need to consider various things and you should be printing out many many many feeds to your terminal every execution.

You have 274 possible locations this robot should be at and you need a way to distinguish what values these locations are getting.

And for the record, next time you do this, make your own jpanel subclass and override the paint method to do custom drawing, it'll be a lot easier.

My guess is that the position of the robot is being updated, but the buttons just need updating with their new icons.

There are many more to learn but they are more complex so i wouldn't expect everyone to know them who program. But i have a personal belief that if you are programming gui's you should know an array how to index one assign values and sort values in one.

Maybe your robotvar doesn't get updated somehow, have you tried printing it to see its' value ?

You'd just need to know the values of the old Position (the button number that the robot was on before moving) and the new Position (the button number the robot has to move to) and set the icons of those buttons.