Thursday, September 08, 2011
The mouse listener edition. . Of course pot shots are easy. How would you do it better? First, the most frustrating thing about Swing is the inability to have a reasonable default behavior. You spend a lot of time getting stuck on silly minutia like this. Second, consider what the opposite behavior would look like. Mouse exited happens when the mouse leaves the entire space occupied by the panel, not just its visible part. Then the same solution would apply, just in the reverse. If you want the mouse to exit when it hovers over a different component, you have the same workaround. Which is the more likely, understood, default behavior? The answer is probably different per component. Which is why the listener framework is irredeemable in Swing - the listeners are just too dumb to be anything but a struggle.
Posted by Yishai at 8:22 AM