[Demonstration 1]

[Buggy Method]
public void update() {
    panel.removeAll();
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    GridBagConstraints c = new GridBagConstraints();
    List<Macro> macroList = Frame.getCalculator().getMacroList();
    if (macroList.size() == 0) {
        panel.add(new JLabel("no macros yet!"));
    } else {
        for (int i = 0; i < macroList.size(); i++) {
            Macro macro = macroList.get(i);
            c.gridy = i;
            c.fill = GridBagConstraints.BOTH;
            c.gridx = 0;
            JLabel label = new JLabel(String.format(" %s ", macro.getName()));
            label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            panel.add(label, c);
            c.gridx = 1;
            panel.add(new MacroButton("Run", (ActionEvent e) -> {
                Frame.getCalculator().setAndRunMacro(macro);
                Frame.getFrame().showCalculator();
            }), c);
            c.gridx = 2;
            panel.add(new MacroButton("Show", (ActionEvent e) -> {
                String listing = macro.getListing();
                String title = "Listing for Macro " + macro.getName();
                JOptionPane.showMessageDialog(Frame.getFrame(), listing, title, JOptionPane.INFORMATION_MESSAGE);
            }), c);
            c.gridx = 3;
            panel.add(new MacroButton("Rename", (ActionEvent e) -> {
                String name = (String) JOptionPane.showInputDialog(Frame.getFrame(), "New name?", macro.getName());
                if (!Frame.getCalculator().commandExists(name)) {
                    macro.setName(name.trim());
                    PanelMacro.this.update();
                }
            }), c);
            c.gridx = 4;
            panel.add(new MacroButton("Delete", (ActionEvent e) -> {
                String message = "Are you sure you want to delete macro " + macro.getName() + "?";
                int response = JOptionPane.showConfirmDialog(Frame.getFrame(), message);
                if (response == JOptionPane.YES_OPTION) {
                    Frame.getCalculator().removeMacro(macro);
                }
                PanelMacro.this.update();
            }), c);
        }
    }
    panel.revalidate();
}

[Buggy Hunk]
if (!Frame.getCalculator().commandExists(name)) {

[Patch]
if (!Frame.getCalculator().commandExists(name) && name != null) {

[Demonstration 2]

[Buggy Method]
public void addButton(String image, double amount) {
    JButton btn = new JButton();
    btn.setIcon(new ImageIcon(tnbbutton.getThumbNailText(dlSystem.getResourceAsImage(image), Formats.CURRENCY.formatValue(amount))));
    btn.setFocusPainted(false);
    btn.setFocusable(false);
    btn.setRequestFocusEnabled(false);
    btn.setHorizontalTextPosition(SwingConstants.CENTER);
    btn.setVerticalTextPosition(SwingConstants.BOTTOM);
    btn.setMargin(new Insets(2, 2, 2, 2));
    btn.addActionListener(new AddAmount(amount));
    jPanel6.add(btn);
}

[Buggy Hunk]
Formats.CURRENCY.formatValue(amount))));

[Patch]
Formats.CURRENCY.formatValue(amount), 12)));

[Demonstration 3]

[Buggy Method]
protected String toNiceLabel(String name) {
    String label = toCamelCase(name).replace('_', ' ');
    StringBuilder b = new StringBuilder(label);
    if (label.length() > 1) {
        boolean space = true;
        for (int i = 1; i < b.length(); i++) {
            char c = b.charAt(i);
            if (!space && Character.isUpperCase(c) && Character.isLowerCase(b.charAt(i - 1))) {
                b.insert(i, ' ');
                space = true;
                i++;
            } else if (c == ' ')
                space = true;
            else
                space = false;
        }
    }
    return b.toString();
}

[Buggy Hunk]
protected String toNiceLabel(String name) {

[Patch]
public static String toNiceLabel(String name) {