public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        // Set up first layer
        int buttonHeight = this.getHeight();
        int buttonWidth = this.getWidth();
        Color topColoring;
        Color bottomColoring;
        if (this.pressed || this.selected) {
            if (this.focus) {
                topColoring = this.selectedColor.darker().darker().darker();
                bottomColoring = this.selectedColor;
            } else {
                topColoring = this.selectedColor.darker().darker().darker();
                bottomColoring = this.selectedColor;
            }
        } else {
            if (this.focus) {
                topColoring = this.buttonColor;
                bottomColoring = Color.black;
            } else {
                topColoring = this.buttonColor;
                bottomColoring = this.buttonColor;
            }
        }
        g2.setPaint(new GradientPaint(0, 0, topColoring, 0, buttonHeight, bottomColoring, false));
        g2.fillRect(0, 0, buttonWidth, buttonHeight);

        // set up paint data fields for second layer
        int highlightHeight = buttonHeight / 2 - HIGHLIGHT_INSET;
        int highlightWidth = buttonWidth;
        if (this.pressed || this.selected) {
            if (this.focus) {
                topColoring = Color.white;
                bottomColoring = this.selectedColor;
            } else {
                topColoring = Color.white;
                bottomColoring = this.selectedColor;
            }
        } else {
            if (this.focus) {
                topColoring = Color.white;
                bottomColoring = Color.black;
            } else {
                topColoring = Color.white;
                bottomColoring = Color.black;
            }
        }
        g2.setPaint(new GradientPaint(0, 0, topColoring, 0, buttonHeight, bottomColoring, false));
        g2.fillRect(0, 0, highlightWidth, highlightHeight);

        //set border
        g2.setColor(Color.black);
        g2.setStroke(new BasicStroke(2));
        g2.drawRect(0, 0, buttonWidth - 1, buttonHeight - 1);

        // Draw the text (if any)
        if (this.getText() != null) {
            g2.setColor(Color.white);
            Font font = g2.getFont().deriveFont((float) (((float) buttonHeight) * .3));
            g2.setFont(font);
            FontMetrics metrics = g2.getFontMetrics();
            Rectangle2D textBounds = metrics.getStringBounds(this.getText(), g2);
            float x = (float) ((this.getWidth() / 2) - (textBounds.getWidth() / 2));
            float y = (float) ((this.getHeight() / 2) + (textBounds.getHeight() / 2)) - metrics.getDescent();
            g2.drawString(this.getText(), x, y);
        }
    }