-
May 3, 2010
Handling mouse events transparently in Swing
Code, TutorialI recently had the task to implement a basic roll-over behavior in a Swing GUI. Pretty simple — or so I thought.
The main problem in Swing is that mouse events are consumed automatically once you employ the very convenient MouseEventHandler, but that might cause some trouble in more sophisticated components. In my case it came down to a JTextPane which can display html and thus had clickable links in it. This JTextPane should be hidden by default and only be visible if a certain element was rolled over by the mouse cursor (similar to a pop-out menu). And there the headaches began: the mouse enter/exit events needed to be captured, but the JTextPane should still receive all mouse events in order to handle the link clicking.
To make things short: this is simple unsolvable in Swing alone. We needs to get our hands dirty and use some of the underlying AWT (yuck!) event handling.
(more…) -
March 27, 2009
Lightweight C++ dictionary
CodeHey there!
Recently, while programming, a well-known question came to me:
How to organize and access resources?
Organization is trivial, whenever there is an order on the objects, so assume there is none. A very nice idea (that might sound somewhat trivial) is simply to give names to resources. Like “pictureOfADog” or whatever. I like the idea of accessing resources just by their names very much, though one needs to devise a data structure that supports naming. Well that is what I have done…
-
March 23, 2009
Small experiment
Code, GeneralThis is something I created while playing around with flash to get new ideas for online games — this will probably evolve into one. The whole thing looked pretty boring until I clamped the maximal number of connections per particle (four in the above). You may see more connections (if particles get too close they will repel each other regardless of how many other connections they have), but those are “unstable” states.
Mesmerizing :)
-
February 22, 2009
“Invalid Python installation”
Code, GeneralI’m kind of a n00b
when it comes to Linux, so this might seem trivial for some — I’m going to note it here anyway, so that my dear co-n00bs may profit from it.Being in love with python, I tried to install pycallgraph to solve performance issues with some scripts (as a very visually oriented person I really prefer to have a nice illustration instead of some cryptic ascii-output). But whatever I tried (rpm, install from scratch, python eggs), it always resulted in the following error:
“error: invalid Python installation: unable to open /usr/lib/python2.5/config/Makefile (No such file or directory)”The solution was awfully simple (and my n00biness has decreased a little as I learn fast from embarrassment): simply installing the development packets (DOH!) for python did the trick. And look at this callgraph:

Awesome! -
February 19, 2009
“Error 1004: Namespace…”
Code, TutorialI currently work on a rather large AS3-project and therefore embraced then newly introduced namespace-concept, especially since I try to stick to a MVC-architecture. Without namespaces, many classes would have to be in the same package (which clutters them unnecessarily) or expose members / methods as public (which throws all the achievements of the OOP-paradigm out of the window). But namespaces solve that gracefully! Well, if they work, anyway.

