if (borderColor != null) {
graphics.setPaint(borderColor);
GraphicsUtilities.drawRect(graphics, 0, 0, width, height);
}
Bounds contentBounds = new Bounds(padding.left + 1, padding.top + 1,
Math.max(width - (padding.left + padding.right + spacing + TRIGGER_WIDTH + 2), 0),
Math.max(height - (padding.top + padding.bottom + 2), 0));
// Paint the content
Button.DataRenderer dataRenderer = menuButton.getDataRenderer();
dataRenderer.render(menuButton.getButtonData(), menuButton, highlighted);
dataRenderer.setSize(contentBounds.width, contentBounds.height);
Graphics2D contentGraphics = (Graphics2D)graphics.create();
contentGraphics.translate(contentBounds.x, contentBounds.y);
contentGraphics.clipRect(0, 0, contentBounds.width, contentBounds.height);
dataRenderer.paint(contentGraphics);
contentGraphics.dispose();
// Paint the trigger
Bounds triggerBounds = new Bounds(Math.max(width - (padding.right + TRIGGER_WIDTH), 0),
0, TRIGGER_WIDTH, Math.max(height - (padding.top - padding.bottom), 0));
GeneralPath triggerIconShape = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
triggerIconShape.moveTo(0, 0);
triggerIconShape.lineTo(3, 3);