The screenshot below is from the application I was talking about in my last post. I got bored fighting with StyledDocument and worked on the overall look of the app. Its not a complete emulation of Mac OS Tiger’s LAF by any stretch of the imagination, but I like the way it looks and I intend to make it better. This is a work in progress.

First, don’t get the wrong idea. I’m not implementing this as a look and feel. It’s just a couple of custom UI classes and overriding some default properties. The point of this is to make an attractive application whose interface is patterned after iTunes 5.0. This is first application I’ve built in long time using NetBean’s Visual Builder (the 4.1 builder, not Matisse).
I put MattBorders on a few of the controls. I’ve never really used MattBorder (or many custom borders at all) before, but in playing around with NetBean’s GUI Editor I found that MattBorder does mostly what I need for this interface. Lets take the tree, splitter, and text pane as an example. First set the divider size to 1 on the splitter. Now, if we had used LineBorder on the tree’s scrollpane, we would have too many lines. With MattBorder you can pass in an Insets to control which sides get a border (a black 1 pixel border in our case). This style also does not put a border on the edges that go up to the edge of the window. Note: The divider still has a dot in the center that I haven’t dealt with yet.
The header and footer are JPanels for which I created a custom UI. I won’t post the code here, it doesn’t really matter. There are many implementations of gradient panels on the net or we could use synth. The important thing is the window design with this style. The brushed metal style created a texture that spanned the entire window and drawing it was slow on older machines. This gradient is less complex that the gradient in the Swing Ocean theme. But you can’t just use the gradient UI with every panel. If the middle content area was a form with labels and text fields then this look would not work very well. I wouldn’t use it for dialogs.
There is a toolbar on the the header with floating disabled and transparent (not opaque). The JSeperators space things out — be sure to set their height to zero otherwise they draw lines. The search component is a blog for another day.
The “Article Title” header is a JPanel with the same gradient UI just with different colors. The “Article Title” itself is a JTextField with the border removed, not opaque, foreground changed to white, and bigger font. The combo box is set not opaque, that really only matters with Apple’s Aqua Look And Feel.
For the tree, we changed the background color. This creates a problem with cell renders still being white. I had created a custom cell renderer before hand to display the icons. Inside the cell renderer I change the foreground for the selected cell to white. Trying to change the background of the cell in the same place doesn’t work. Trying to set the cell renderer to transparent doesn’t work. Instead use something like the following…
DefaultTreeCellRenderer ren = new CTreeRenderer();
tree.setCellRenderer(ren);
tree.setBackground(new Color(0xE7EDF6));
ren.setBackgroundNonSelectionColor(tree.getBackground());
ren.setBackgroundSelectionColor(new Color(0x3F7EDC));
ren.setBorderSelectionColor(ren.getBorderSelectionColor());
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
This looks pretty neat until you select a cell. In iTunes the entire row is highlighted and the highlight is a gradient. I don’t care about a gradient highlight personally, but I’d like the highlight to extend to width of the window. This likely means overriding the UI of the tree to pick the slack (see Tiger Trees) since the cell doesn’t actually take up the entire width of the window. That also means we probably couldn’t use synth to do it (even if I wanted too).
The “Document Title” area is a JPanel with the gradient UI again. The thumb button in iTunes is an extra widget to resize the splitter for people that have trouble getting their mouse on the one pixel divider. I haven’t implemented this yet (blog for another day). But the button itself is a PNG and the button set to not draw the content area or the border.
The name of the application is likely to change. I imagine the name I used in the screenshot is already used by some other application. And when I finish the application, it will likely be open source. More Later.