I don't know if this is appropriate to Swing/AWT, or even if this is a Java issue, but I had quite a shock recently. I have been working on a kind of drawing program in which the user can select tiny control rectangles and drag them around, causing the shape of a polygon to change. (They are not implemented as Java Polygons or Shapes because some are one-dimensional). I have gotten it into pretty good shape, so I exported it from Eclipse, my development platform, into a standalone Java application. In the standalone application, each time I drag the mouse, the redrawing shows nasty flickering, as if it's running too slowly. While I was developing the application inside Eclipse, it ran perfectly, with no flickering whatsoever.
What gives? I'd expect that the in-Eclipse runs would be slower, because they're burdened with extra debugging baggage, while the exported standalone version should run faster. But the reverse is the case.
Thanks for the suggestion. I expanded the space to a gigabyte but it had not effect. I think that I shall have to develop some clever optimization algorithms.
Another possibility: Eclipse is loading a different graphics library than what you get running standalone. Add the -verbose:class option to your command line (both in Eclipse and standalone). This option prints the name of each class loaded and the full path of the jar it came from. Look for graphics classes. That might give you some clues (it solved a few for me when I noticed Eclipse behavior different from command line behavior).
I'm guessing that part of my problem lies in various software incompatibilities. I'm still using an ancient Mac Pro from 2006 -- eight years old! It was always adequate for my needs, but just in the last months it has been showing its obsolescence. I'm stuck with OS 10.7.5. Safari is starting to screw up. My image editing program (Pixelmator) is malfunctioning. And now this problem with Java. So I broke down and ordered a new Mac and expect to get it later this week. Does anybody want to bet that this WON'T fix all my problems?
I think that I should adopt a new signature: Pennywise and Pound Foolish.
Another possibility is that you're using (say) Java 7 in one place and Java 6 in the other.
I'm pretty sure that's the problem. I have installed Java 7 on my Mac but, just to make sure, I checked and, sure enough, Eclipse was default-setting the build to Java 6. I changed the build to Java 7 and now it refuses to compile. I'll do some research before asking for help; it's probably something just as dumb as this mistake.
I got my new iMac with Mavericks yesterday, and I've been an installin' fool for the last 24 hours, but I think I've gotten it up to speed. I downloaded the latest Eclipse and tried out my project, and it worked perfectly both inside and outside Eclipse. So it appears that the suggestions made by Paul Clapham and Peter Johnson were correct. We thus have a general rule for dealing with some problems with Java: buy a new computer. ;-)