The Joy of Writing Swing Frameworks

Technology 6 Comments »

One of the best parts of writing frameworks around Java’s Swing GUI toolkit is how often components don’t actually follow the component contract.

For example, JComponent defines a FocusListener which predictably enough fires an event when a component receives and loses focus. Yet, many components in Swing and its ecosystem (e.g., JComboBox) simply fail to fire a focus event. Why? Because they are composite components (i.e., they are comprised of several components mashed up together) and they expect you to get some of the internal components and register the FocusListener on one of them. Mind, this is rarely documented, adding to the fun.

No no no no! I wish Swing’s team published some kind of “requirements to be a component” document or “best practices” document that did away with this foolishness. Writing a framework that treats components generically is next to impossible (i.e., requires a special adapter layer that makes all components obey some kind of contract) thanks to all of this–to say nothing of the poor newbie.

3 GB is the MacBook Pro Sweet Spot

Technology 9 Comments »

Since the price on a 2 GB MacBook Pro-compatible SO-DIMM recently entered the atmosphere on NewEgg.com, I went for it. I’m very, very pleased. My MacBook Pro generally performed well with 2 GB, but when I launched Parallels, I’d have to trim down my working set to make sure my system didn’t crawl.

After the upgrade, I can leave my full OS X working set up while Parallels does its thing and it all works fine (allocating 700 MB to a WinXP VM). Once thrashing starts during an OS X / Parallels session, man, game over.

No More Wildcard Imports

Technology 3 Comments »

I’ve long been fascinated by the impact that a culture’s language has on its thought processes and social interactions. Is the ease by which adjectives become nouns in Spanish a major factor in their culture of commonly calling people “fat one” (gorda), “old one” (vieja), and so forth?

In a related area, I’m interested in the changes that better tools have brought to the code that I write. For example, despite the advantages of Java 5’s enhanced For loop construct, I’ve only used it a couple of times because IntelliJ IDEA makes it so easy to write loops by typing “itli[tab]” and so forth.

And because of tools, today I finally stopped using wildcard imports. When I first starting writing Java code, I would frequently import “java.util.*” and so forth. In recent years, the IDE will automatically write the import for me, but it would often switch to wildcard imports once a certain number of classes from a package were used, or when certain packages were used (java.swing and java.awt, for example).

I decided that it just doesn’t make any sense to do wildcard imports, largely because file sizes are completely irrelevant to me and its worth sparing myself from the occasional conflict (java.awt.List, anyone?) to splurge on the extra bytes writing out import lines.

Watching the Car Rental Train Wreck in Slow-Motion

Life 2 Comments »

I’m a big fan of today’s travel-friendly world. I fly a bit more than I’d like, but I’m very happy that I can regularly leave my house an hour before a flight, drive 25 minutes to the airport, and walk onto the plane 25 minutes before takeoff (don’t try that in a big city). Normally, on the other end, I can get from my arrival gate to the inside of my rental car in anywhere from 10 minutes (e.g., EWR, JFK) to 20 minutes (e.g., SJC, OAK, ATL). For someone who has adjusted his life in many ways to avoid waiting in lines or otherwise wasting time, this is great stuff.

All of this, of course, is completely moot when traveling with the (four very young) kids. The biggest pain point is the rental car at the other end. So painful, in fact, that we usually drive to many of our vacation destinations rather than fly. But sometimes, we have to fly.

Avis generally is a no-hassle rental car experience (except for that time I left my driver’s license at the other airport). But when you need a car seat? Horrors. Four car seats? (Shudder.)

So for variety, this time I switched to Hertz. And man, was I ever punished for it. From the first moment when I walked up to the express lane line and was greeted with a lovely “Hey there’s only one line sir!” shout from behind the counter, I knew I was in for a treat.

As the line piled up behind me, the clock rounded 2 am, and the amount of time it took for two employees to service a customer continued its steady rise past 20 minutes, the tension in the air was palpable. A few Wall Street types finally broke down, shouting something about how important they were as they left the line to shout loudly into their PDA-phones in their vain attempts at other ways out of the Hertzatz quagmire.

My favorite part of the experience was how the agents sent the customers out to check and see if their car was in fact there, and both times it wasn’t.

I have no idea what happened to the rest of the poor saps in line, as I was #3, and though it took them a full 20 minutes to service me (including for some reason inexplicably blanking out all of my personal information character-by-character in their green-screen application and re-entering it all over again, character-by-character), I was so ecstatic to have actually gotten the car I reserved by the end of it all and miss the inevitable riot that was to ensue in the coming hours. I have not scoured local news but I would not be surprised to learn that the Hertz location at Newark International Airport was burned to the ground at some point that evening, with the two stock-brokers I sailed past on my way out charged with any associated crimes.

More on the Amazing IntelliJ IDEA

Technology 5 Comments »

When I code Java Swing UIs, I often use Karsten Lentzsch’s excellent JGoodies Forms library to scale my pixel measurements in accordance with the font DPI setting of the underlying operating system (e.g., to properly support Windows’ “Large Fonts” setting). This is done by employing a symbolic measurement unit called a “DLU” (dialog unit) in place of pixels at design-time and then converting the DLU value to a pixel value at run-time.

An unfortunate aspect of the library’s design is that I have to invoke separate methods for converting the units along the X-axis and Y-axis (i.e., I invoke Sizes.dialogUnitXAsPixel and Sizes.dialogUnitYAsPixel). This lends itself to many a subtle bug.

To my amazement, my trusty IDEA was once again one step ahead of me:

Invoking the wrong dialog unit conversion method

Notice in the overly-small screen-shot above that I’m passing a constant containing the word “HEIGHT” into a method that’s expecting a unit value along the X axis. I’m not sure what algorithm IDEA employs to figure this out, but I say again, wow.

Once again, money well spent.

When 24 is not 24…

Life 1 Comment »

Driving around mid-town Manhattan at 3 am. Turn into parking garage with big “Open 24 Hours” sign. Closed. Back-up, avoiding a collision with one of the many pedestrians walking around on the surprisingly lively streets. Drive one block. Look before turning into second garage with big “Open 24 Hours” sign. Closed. Repeat with a third. Finally, find a forth that’s open.

Ugh.

You Know You’re a Geek When…

Technology 1 Comment »

I took a day-trip to San Francisco yesterday to participate in a panel at O’Reilly’s Web 2.0 Expo. I’ve been through SFO a kabillion times. For as long as I can remember, they’ve had this mini-museum in the United terminal going towards Gates 76+. In all that time, I’ve never, ever stopped to look at any of the displays.

Until yesterday:

Atari 2600

I’m embarrassed to say I got a little emotional looking at the games, each of which I played endlessly as a little boy, and recalled many memories of fighting with my brothers, beating high scores, leaving the 2600 on for hours so I could do chores and come back and pick up where I left off (all about the score), and so forth.

You can find an emulator and play Yars Revenge, but you can’t go back to the good ol’ days. Sniff.

GroupWise Exporter 1.0

Technology 9 Comments »

I’ve received a few emails and at least one comment on my earlier blog entry about my GroupWise to iCalendar converter, so as promised, I hereby release GroupWise Exporter 1.0. Its a Java application, but I only support it on the Mac. Sorry. If anyone has a desire to use it on non-OS X machines, let me know. Wouldn’t be that hard to get it working cross-platform. Enjoy, and let me know if you have any problems running it.

Oh, and be warned, it stores your GroupWise password in the clear in a preferences file in your home directory. Sorry about that. Would be easy to encrypt it. Maybe a 1.1 feature…

UPDATE: Source code available.

Vista Problem Solved, Sort Of

Technology 4 Comments »

I’ve recently been whining about Vista blue-screening on me. Just after wiping it off the affected system, Tim Heuer from Microsoft offered to help me troubleshoot the problem. After re-installing and having another few blue-screens, I passed him the MEMORY.DMP files (~150 MB each via TransferBigFiles.com, a great free service). And guess what he found?

While Vista told me that the problem was with the video driver, it turns out that the problem was… my unsupported RAID driver from Intel. When I first had a blue-screen, it occurred to me that was the problem, but since Vista so confidently diagnosed the issue as a video driver issue, and since the RAID array has seemed to work perfectly (i.e., no data corruption), I stopped worrying about it.

Tim assures me the problem is with the RAID driver so… not only do I feel stupid for whining publicly about an instability caused by a RAID driver not designed for use with Vista, but I’m going to have to once again wipe off Vista and install a different OS since Intel makes it clear on their site my hardware is not supported under Vista.

Ugh.

Exporting GroupWise to iCal

Technology 4 Comments »

I have a client that uses Novell’s GroupWise (GroupWise!) and its one of those “we schedule it on your calendar and expect you to show up” shops, so I have to make reviewing GroupWise part of my workflow.

The OS X (Java-based) client is so painful, and my life already so organized around Apple’s iCal, that I found it much more convenient to aggregate GroupWise into iCal. Lacking the capability of exporting to iCalendar format, I wrote my own exporter that scrapes the “low-bandwidth” web interface and converts it, serving it up via an embedded web server.

GroupWise Exporter

I released it to a few people, but have never made the code broadly available. So, I’ll announce here that its available, and if anyone wants it, let me know and I’ll post it publicly.

(Just to clarify, this is not an April Fool’s joke.)

UPDATE: I’ve made this application publicly available.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login