public static void renderSurface( Graphics g, Container c, Rectangle rect, boolean toSimulateRollover, boolean hasTopBorder, boolean hasBottomBorder) { CellRendererPane buttonRendererPane = new CellRendererPane(); JButton rendererButton = new JButton(""); rendererButton.getModel().setRollover(toSimulateRollover); buttonRendererPane.setBounds(rect.x, rect.y, rect.width, rect.height); Graphics2D g2d = (Graphics2D) g.create(); g2d.clipRect(rect.x, rect.y, rect.width, rect.height); buttonRendererPane.paintComponent( g2d, rendererButton, c, rect.x - rect.width / 2, rect.y - rect.height / 2, 2 * rect.width, 2 * rect.height, true); g2d.setColor(FlamingoUtilities.getBorderColor()); if (hasTopBorder) { g2d.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); } if (hasBottomBorder) { g2d.drawLine( rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); } g2d.dispose(); }