The way I see it (correct me) is that Toolkit interacts directly with the specific OS or windowing system and the subclasses of Toolkit are used to write higher level code (Where I wouldn't have to worry about specific OSs). So, if I had run this program on another computer the stuttering might not have happened because they could have possible had a different windowing system that didn't buffer graphics events? I'm running Mandriva Linux, but a different OS might not have had this problem?
I didn't tested it but it seems it's required at least for Linux, but probably not needed on Windows. Sometimes I see the problem on Java applets/apps, probably because author did test on only one platform. Maybe the BufferedStrategy synchronizes on other platforms but not on Linux. In this case, this could be considered as a bug in BufferedStrategy, as it's clear what the intentions are when swapping buffers.
So the reason it ran without stuttering when I moved the mouse was because the windowing system updated on a mouse move?
- In the space invader game tutorial for java sync wasn't used and it runs without stuttering on my machine, why is this?
Probably because the events were flushed by other operations (eg. after filling up some buffer or time).
- If I had incorporated a mousemove listener or something that had to do with the mouse would it still stutter?
I don't think that listeners matter to this issue.
- Is there another way to solve this problem without sync() or is sync the best way?
I think it's the correct solution.
It's similiar to I/O operations, on different platforms it behaves differently, but according the specs. If you forgot to handle some case though, it will work on one system and crash/misbehave on another.
Sorry for all the questions, I'm just curious about how all the different components interact. I think I understand the coding process well, but when writing code for games knowledge of how different operating systems, gfx cards, etc.. seems to be needed and I'll take whatever I can get. If anyone could point me in the right direction where I could learn about theses processes I'd really appreciate it.
Many of these things are small nuances that can be found only at random or when you hit problem. It's very important to test on all platforms you're supporting. And even with that other people will still get problems in these details, like the issue with French's AZERTY vs QWERTY keyboard layout mentioned in some other recent thread here.