* If the <code>component</code> component is the child of a <code>JViewPort</code>
* instance this border will be installed on its scroll pane parent.
*/
public static void installFocusBorder(JComponent component) {
if (unfocusedViewBorder == null) {
Border unfocusedViewInteriorBorder = new AbstractBorder() {
private Color topLeftColor;
private Color botomRightColor;
private Insets insets = new Insets(1, 1, 1, 1);
{
if (OperatingSystem.isMacOSX()) {
this.topLeftColor = Color.GRAY;
this.botomRightColor = Color.LIGHT_GRAY;
} else {
this.topLeftColor = UIManager.getColor("TextField.darkShadow");
this.botomRightColor = UIManager.getColor("TextField.shadow");
}
}
public Insets getBorderInsets(Component c) {
return this.insets;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Color previousColor = g.getColor();
Rectangle rect = getInteriorRectangle(c, x, y, width, height);
g.setColor(topLeftColor);
g.drawLine(rect.x - 1, rect.y - 1, rect.x + rect.width, rect.y - 1);
g.drawLine(rect.x - 1, rect.y - 1, rect.x - 1, rect.y + rect.height);
g.setColor(botomRightColor);
g.drawLine(rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height);
g.drawLine(rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height);
g.setColor(previousColor);
}
};
if (OperatingSystem.isMacOSXLeopardOrSuperior()) {
unfocusedViewBorder = BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(UIManager.getColor("Panel.background"), 2),
unfocusedViewInteriorBorder);
focusedViewBorder = new AbstractBorder() {
private Insets insets = new Insets(3, 3, 3, 3);
public Insets getBorderInsets(Component c) {
return this.insets;
}