public void paint(Graphics g) {
            // Set up graphics and buffer
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            BufferedImage buffer = GraphicsManager.gc.createCompatibleImage(this.getWidth(), this.getHeight(), Transparency.TRANSLUCENT);
            Graphics2D gb = buffer.createGraphics();
            gb.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

            // Set up first layer
            int buttonHeight = this.getHeight() - INSET * 2;
            int buttonWidth = this.getWidth() - INSET * 2;
            int arc = buttonHeight;

            if (this.pressed || this.selected) {
                g2.setPaint(new GradientPaint(0, -buttonHeight, Color.darkGray, 0, buttonHeight, canvas.getColor(), false));
                g2.fillRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc);
                g2.setColor(Color.darkGray);
                g2.drawRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc);
            } else {
                //paint highlightlayer
                if (this.focus) {
                    gb.setColor(Color.yellow);
                    gb.setStroke(new BasicStroke(3));
                    gb.drawRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc);
                    gb.setStroke(new BasicStroke(1));
                }
                // Paint the first layer
                gb.setColor(canvas.getColor().darker());
                gb.fillRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc);
                gb.setColor(Color.black);
                gb.drawRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc);

                // set up paint data fields for second layer

                int highlightHeight = buttonHeight * 2 / 3;
                int highlightWidth = buttonWidth;
                int highlightArc = highlightHeight;

                // Paint the second layer
                gb.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .8f));

                gb.setColor(canvas.getColor());
                gb.setClip(new RoundRectangle2D.Float(INSET, INSET, highlightWidth, highlightHeight, highlightArc, highlightArc));
                gb.fillRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc);

                // Blur
                ConvolveOp blurOp = new ConvolveOp(new Kernel(3, 3, BLUR));
                BufferedImage blurredImage = blurOp.filter(buffer, null);

                // Draw button
                g2.drawImage(blurredImage, 1, 1, null);
            }
            // Draw the text (if any)
            String text = canvas.getName();
            if (text != null && buttonHeight > 4) {
                //Font font = g2.getFont().deriveFont((float)(((float)this.getHeight()) * .6));
                Font font = g2.getFont().deriveFont((float) (this.getHeight() - INSET * 2 - 2) * .7f);
                g2.setFont(font);
                FontMetrics metrics = g2.getFontMetrics();
                Rectangle2D textBounds = metrics.getStringBounds(text, g2);
                float x = (float) ((this.getWidth() / 2) - (textBounds.getWidth() / 2));
                float y = (float) ((this.getHeight() / 2) + (textBounds.getHeight() / 2)) - metrics.getDescent();

                g.setColor(Color.black);
                for (int i = 0; i < shadowPositionArray.length; i++) {
                    int dx = shadowPositionArray[i][0];
                    int dy = shadowPositionArray[i][1];
                    g2.setColor(new Color(0.5f, 0.5f, 0.5f, shadowColorArray[i]));
                    g2.drawString(text, x + (int) ((dx) * offsetSize), y + (int) ((dy) * offsetSize));
                }
                if (canvas.getHighlight() != null) {
                    g.setColor(canvas.getHighlight());
                } else {
                    g.setColor(Color.white);
                }
                g2.drawString(text, x, y);
            }
            if (canvas.getHighlight() != null) {
                g2.setStroke(new BasicStroke(3));
                g2.setColor(canvas.getHighlight());
                g2.drawRoundRect(INSET + 1, INSET + 1, buttonWidth - 2, buttonHeight - 2, arc, arc);
                g2.setStroke(new BasicStroke(1));
            }
        }