Fix your JScrollPane's resizable corner under Aqua
Regular mac windows have a grippy control in the bottom right hand corner that allows you to resize the window. Unfortunately, most Swing apps don't take this control into consideration, and it's painted right over their precious scrollbar buttons! Here's two versions of the same application, before and after fixing the problem:Fortunately, there's a fix. Either use the most excellent quaqua look and feel, or use my simple ScrollPaneLayout hack:
/**
* A scrollpane layout that handles the resize box in the bottom right corner.
* @author <a href="mailto:jesse@swank.ca">Jesse Wilson</a>
*/
public class MacCornerScrollPaneLayoutManager extends ScrollPaneLayout {
private static final int CORNER_HEIGHT = 14;
public static void install(JScrollPane scrollPane) {
if(System.getProperty("os.name").startsWith("Mac")) {
scrollPane.setLayout(new MacCornerScrollPaneLayoutManager());
}
}
public void layoutContainer(Container container) {
super.layoutContainer(container);
if(!hsb.isVisible() && vsb != null) {
Rectangle bounds = new Rectangle(vsb.getBounds());
bounds.height = Math.max(0, bounds.height - CORNER_HEIGHT);
vsb.setBounds(bounds);
}
}
}