Poker Stats: Getting the Mac Feel Right

I can always tell when a Mac app is a quick port from Windows done by people who haven’t taken the time to grok the OS X environment. Things just aren’t quite right. For example, in OS X, the keystroke Command+, always brings up Preferences. Additionally they are always available from a standard location on the menu bar. Always? Did I say always? I meant always except for those who just dump a Windows app onto the Mac with the bare minimum work required to get in running.

I’m trying very hard to get the Mac feel right. I’m grateful to Apple for providing ample quality documentation in this area. For example, the Apple guidelines specify the preferred size and location of new windows. Horizontally centred, vertically with a gap between the top of the window and the screen equal to half the gap below the window.

I’ve created a helper method in my SwingUtils class to take care of locating new windows for me. Here’s the source:

* Aligns the position of an object (dialog, window, frame) so that it is located
* according to the Apple UI guidelines.
* @param window object to locate
public static void alignObject(final Window window) {
final Dimension size = window.getSize();
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int x = ((int) screenSize.getWidth() – (int) size.getWidth()) / 2;
int y = ((int) screenSize.getHeight() – (int) size.getHeight()) / 3;
window.setLocation(new Point(x, y));