Saturday, April 25, 2009

Move and Resize windows on Mac OS X

I have been always extremely annoyed by the fact that one cannot resize the windows on Mac OS X using all four edges of the window. In fact that is one of the most aggravating thing for me about using a Mac. Another issue is that one cannot use the keyboard to move and resize the windows. I was aggravated enough to make me write a tool to address just those issue. I wrote the MoveResize tool. It make synergistic use of Applescript and Java to fix IMHO a major usability flaw in Mac OS.

How it works (Swing version)

The implementation uses Applescript to get the frontmost window and it's bound. It sends the bounds rectangle to a server implemented in Java over a socket connection. The Java server takes the screen shot of the full Desktop and uses it as the Image label (a JLabel with ImageIcon) as the content pane of an undecorated JFrame which has the same bounds as the Desktop. A JPanel with semitransparent background and a dark rounded rectangular border is given the same bounds that were received over the socket. This JPanel is added to the PALETTE_LAYER of the JFrame's layered pane - which makes it appear floating in front of the front window. Mouse and Key listeners on the JPanel allows moving and resizing of the JPanel. When the user types the ENTER key the JFrame is hidden and the new bounds of the JPanel are sent back to the Applescript over the socket connection which moves and resizes the frontmost window.

Initially I had implemented the original version using SWT. However, it turns out that it is implementable in Swing also - once again proving that Swing is a very good toolkit. Added advantage is that Swing is part of the JDK making the implementation much much smaller. BTW the Swing implementation is much faster and plays nicely with log off and shutdown.

Watch Screencast


Here is a screenshot:



4 comments:

Reaper said...
This comment has been removed by a blog administrator.
Anonymous said...

Hello there,

Thanks for sharing this link - but unfortunately it seems to be down? Does anybody here at sandipchitale.blogspot.com have a mirror or another source?


Cheers,
Oliver

Sandip Chitale said...

Hi Oliver,

Please use the better tool:

Mac Win Man.

Anonymous said...

Hey - I am definitely happy to find this. great job!