scruffles.net subscribe
Monday, March 29, 2010

It's been on my todo list for well over a year now, but I've finally taken the time to redesign my blog. Since I switched to blogger I've been using an altered blogger theme that never really sat right with me (front image below). When I was using moveable type, I had created my design from scratch including a photo I had taken of a circut board (middle image). Considering myself a creative person, using someone else's website template really bothered me. It felt good to get this done.



Other than the actual photo of the cork (which I lifted from deviant art), everything here is original. I created all the artifacts from scratch in Photoshop and even took a picture of myself for the top corner. I'm using CSS and Javascript (JQuery) to make the flickr badge at the left look like images taped to the cork. There are a few rough edges I'd like to clean up, but overall I feel much better to have something original up again.

Saturday, March 20, 2010

Having used Macs for a number of years, I've become accustomed to being able to drag windows around by the window's outer most frame (the toolbar, statusbar or the outer border of the window). When I run a program that doesn't have this behavior (even one of my own), it almost feels broken.

I put together a piece of code which adds a MouseListener to any Swing component so dragging it will drag the entire Frame (or Dialog). Here's the behavior I'm trying to reproduce:



It isn't too difficult to implement. You can try out the results here:



The source is available on github.

Wednesday, March 17, 2010

While tinkering around at home I produce a lot of small snippets of code that aren't complete projects but come in handy in the future. A lot of times these end up in my programming notes for later (every developer should keep a TiddlyWiki). Recently I've decided that my blog is just as good as any place for some of these pieces of code. My first post will be a vertical button:

I was trying to create a hide-away panel like the project tab in IDEA:



I found several examples online, but didn't like the implementation. One overrode paint() and drew everything from scratch. Another kept a delegate component to do all the painting (which means you have to delegate all the button's properties to the delegate if you want them to apply to the button).

My implementation just rotates the graphics object before painting. The only other trick is to invert the height and width. The source is available on github.


Pros
  • All the button's view properties still work (icons, borders, margins, etc)

Cons
  • Preferred size is being mis-reported
  • Similar change might be needed for min/max size for some layouts
  • Text in the Motif look and feel doesn't seem to rotate correctly (at least on my Mac)

Bryan