Log in

current entries friends' entries archives about me Previous Previous Next Next
Work Amusement - cellophane
the story of an invisible girl
Work Amusement
I subclassed a Java class quite some time ago: the JComboBox. I did so to adjust its default behavior to match how we want our combo boxes to work here. Wanting to make another change, I looked over the source code again. When I originally did the work, I had to make quite a few additions -- plus I overrode two additional Java inner classes, so it would behave like I wanted it to. I commented what I did thoroughly, and some of my comments made me chuckle when I read them over today. At least I was honest....

// attempt to remove enter key. This doesn't actually work.

* The following was copied from Java code for JComboBox:
* (But I'm overriding it anyway.)
* "This method is public as an implementation side effect.
* do not call or override."

* The purpose of this inner class is to override a single method in the
* BasicComboPopup computerPopupBounds, to cause the combo to go up
* instead of down, if going down will cause it to go off the Window
* which contains it. Java's version checks the screen size instead of
* the Window size, causing it to sometimes be obscured by the start bar.
* In order to do this I had to extend BasicComboPopup, instead of
* WindowsComboPopup, because of its protected class status. However I
* didn't see much utility in the Windows version, in fact none of the
* things it says it does really work, that I've noticed, so I don't think
* it will be a problem.
read 3 comments | talk to me!
fls From: fls Date: June 20th, 2002 10:30 am (UTC) (Link)
Seriously, I've had more problems w/JComboBox and its never ending list of hidden action events than I'd care to remember.

My personal favorite is firing action events when the user is merely browsing a JComboBox's contents.
renniekins From: renniekins Date: June 21st, 2002 09:55 am (UTC) (Link)
Browsing using the arrow keys? Yeah, that's an interesting one. It's a challenging little componant, that's for sure....!
hoshisabi From: hoshisabi Date: August 6th, 2004 10:09 am (UTC) (Link)

Favorite Comments in Code

My favorite comment in code from someone else was:

"Think twice before you change this!"

The code was wrong. the old programmer had struggled with a way to do some sort of date calculation (that I cannot remember). All I remember was that I replaced a sixty or so line procedure with a three line routine.

If I remember right, my logic was basically: "Construct a date from the string: month + constant/ 1 / year, subtract one day from it using the date class, then you have the end date of your beginning month plus some constant."

It didn't stop me from having to invite about five people to a code review because everyone was s cared of that one comment. (They had assumed that since the comment was so ominous that our date classes didn't work correctly.)

We tend to have scarier things happen in initial values in our code, rather than the comments.

Our initial value of many integers is 4242, we've had timers that initially say "You might as well take a nap, this will never finish", and default error messages saying, "Jeff broke it." (Jeff was not me, heh.)

The best story was when two designers kept moving where a text box was located, eventually one of them made the default text of the box "Jeff is a weenie." It went out into the field that way. When a bug was found in the code, it displayed that initial value -- to a customer named Jeff.

... We've fixed that initial text since then.
read 3 comments | talk to me!