import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

public final class ButtonNPE extends JFrame {

    public ButtonNPE(final String title) throws HeadlessException {
        super(title);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        add(new JRoundedButton("mini"));
        setSize(300, 300);
        setVisible(true);
    }


    public static void main(final String[] args)
            throws InvocationTargetException, InterruptedException {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                new ButtonNPE("Button NPE");
            }
        });
    }

    class JRoundedButton extends JButton {

        JRoundedButton(final String text) {
            super(text);
        }

        @Override
        protected void paintComponent(final Graphics g) {
            BufferedImage bi = new BufferedImage(getWidth(), getHeight(),
                                                 BufferedImage.TYPE_INT_ARGB);
            Graphics gg = bi.createGraphics();

            super.paintComponent(gg);
            gg.dispose();
        }
    }
}

