Archive for April, 2007

Swing has it backwards

Monday, April 2nd, 2007

One of the questions that I have been asked (and have asked myself) is why I’m even doing this project when Swing seems to give you a viable alternative. For example, for a JList, you can grab the ListModel and use it to register for event changes on the JList. At first, this all seems well and good, except for a really important issue: this is backwards.

(more…)

be careful of the hashCode()

Sunday, April 1st, 2007

Update:

As it turns out, I was (mostly) being a horse’s ass.  It was a bit difficult to find, but Java does provide a mechanism for getting the equivalent of Object.hashCode() on any given object (not in a general way, i.e. get the un-overridden behavior, but for this case specifically).  That method is System.identityHashCode().

One of the side-effects of the way Java is designed is that it is hard to identify an object. By this, I don’t mean identifying it by its apparent value, as in a List is the same as another list with the same stuff in the same order. What I mean is identifying an object as this object, not by its value, but by its physical existence in the whole program world thingamabobber. This usually isn’t too big of a problem, until you really start working with the collection framework’s HashMap.

(more…)


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.