package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;

public class MainPanel extends JPanel {
    public MainPanel() {
        super(new BorderLayout());

        String[] columnNames = {"Integer", "String", "Boolean"};
        DefaultTableModel model = new DefaultTableModel(null, columnNames) {
            @Override public Class<?> getColumnClass(int column) {
                switch(column) {
                  case 0:  return Integer.class;
                  case 2:  return Boolean.class;
                  default: return String.class;
                }
            }
        };
        model.addTableModelListener(new TableModelListener() {
            @Override public void tableChanged(TableModelEvent e) {
                DefaultTableModel model = (DefaultTableModel)e.getSource();
                editor.setVisible(model.getRowCount()==0);
            }
        });

        JTable table = new JTable(model);
        table.setAutoCreateRowSorter(true);
        table.setFillsViewportHeight(true);
        table.setComponentPopupMenu(new TablePopupMenu());
        table.setLayout(new GridBagLayout());

        String str = "<html>No data! <a href='dummy'>Input hint(beep)</a></html>";
        JEditorPane editor = new JEditorPane("text/html", str);
        editor.setOpaque(false);
        editor.setEditable(false);
        editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
        editor.addHyperlinkListener(new HyperlinkListener() {
            @Override public void hyperlinkUpdate(HyperlinkEvent e) {
                if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) {
                    java.awt.Toolkit.getDefaultToolkit().beep();
                }
            }
        });
        table.add(editor);
        add(new JScrollPane(table));
        setPreferredSize(new Dimension(320, 240));
    }
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }catch(Exception e) {
            e.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

class TablePopupMenu extends JPopupMenu {
    private final Action addAction = new AbstractAction("add") {
        @Override public void actionPerformed(ActionEvent e) {
            JTable table = (JTable)getInvoker();
            DefaultTableModel model = (DefaultTableModel)table.getModel();
            model.addRow(new Object[] {0, "aaa", Boolean.FALSE});
            Rectangle rect = table.getCellRect(model.getRowCount()-1, 0, true);
            table.scrollRectToVisible(rect);
        }
    };
    private final Action deleteAction = new AbstractAction("delete") {
        @Override public void actionPerformed(ActionEvent e) {
            JTable table = (JTable)getInvoker();
            DefaultTableModel model = (DefaultTableModel)table.getModel();
            int[] selection = table.getSelectedRows();
            if(selection==null || selection.length<=0) return;
            for(int i=selection.length-1;i>=0;i--) {
                model.removeRow(table.convertRowIndexToModel(selection[i]));
            }
        }
    };
    public TablePopupMenu() {
        super();
        add(addAction);
        addSeparator();
        add(deleteAction);
    }
    @Override public void show(Component c, int x, int y) {
        JTable table = (JTable)c;
        int[] l = table.getSelectedRows();
        deleteAction.setEnabled(l!=null && l.length>0);
        super.show(c, x, y);
    }
}

@@ -304,32 +304,655 @@
 BorderLayout());
+%0A        String str = %22%3Chtml%3ENo data! %3Ca href='dummy'%3EInput hint(beep)%3C/a%3E%3C/html%3E%22;%0A        final JEditorPane editor = new JEditorPane(%22text/html%22, str);%0A        editor.setOpaque(false);%0A        editor.setEditable(false);%0A        editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);%0A        editor.addHyperlinkListener(new HyperlinkListener() %7B%0A            @Override public void hyperlinkUpdate(HyperlinkEvent e) %7B%0A                if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) %7B%0A                    java.awt.Toolkit.getDefaultToolkit().beep();%0A                %7D%0A            %7D%0A        %7D);
 %0A%0A        String
@@ -1899,626 +1899,8 @@
 ());
-%0A%0A        String str = %22%3Chtml%3ENo data! %3Ca href='dummy'%3EInput hint(beep)%3C/a%3E%3C/html%3E%22;%0A        JEditorPane editor = new JEditorPane(%22text/html%22, str);%0A        editor.setOpaque(false);%0A        editor.setEditable(false);%0A        editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);%0A        editor.addHyperlinkListener(new HyperlinkListener() %7B%0A            @Override public void hyperlinkUpdate(HyperlinkEvent e) %7B%0A                if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) %7B%0A                    java.awt.Toolkit.getDefaultToolkit().beep();%0A                %7D%0A            %7D%0A        %7D);
 %0A   

Fix error