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

public class MainPanel extends JPanel {
    private final String[] columnNames = {"String", "Integer", "Boolean"};
    private final Object[][] data = {
        {"aaa", 12, true}, {"bbb", 5, false},
        {"CCC", 92, true}, {"DDD", 0, false},
    };
    DefaultTableModel model = new DefaultTableModel(data, columnNames) {
        @Override public Class<?> getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }
    };
    private final JTable table       = new JTable(model);
    private final JScrollPane scroll = new JScrollPane(table);
    private final JCheckBox check    = new JCheckBox("Disable Scrolling");
    public MainPanel() {
        super(new BorderLayout());
        TableColumn col = table.getColumnModel().getColumn(0);
        col.setMinWidth(60);
        col.setMaxWidth(60);
        col.setResizable(false);

        for(int i=0;i<100;i++) { model.addRow(
            new Object[] {"Name "+i, Integer.valueOf(i), Boolean.FALSE}); }

        check.addItemListener(new ItemListener() {
            @Override public void itemStateChanged(ItemEvent ie) {
                JCheckBox box = (JCheckBox)ie.getSource();
                table.clearSelection();
                boolean flag = !box.isSelected();
                JScrollBar bar = scroll.getVerticalScrollBar();
                bar.setEnabled(flag);
                scroll.setWheelScrollingEnabled(flag);
                table.setEnabled(flag);
            }
        });

        scroll.setComponentPopupMenu(new TablePopupMenu());
        table.setInheritsPopupMenu(true);

        add(scroll);
        add(check,  BorderLayout.NORTH);
        setPreferredSize(new Dimension(320, 240));
    }

    class TestCreateAction extends AbstractAction{
        public TestCreateAction(String label, Icon icon) {
            super(label,icon);
        }
        @Override public void actionPerformed(ActionEvent evt) {
            testCreateActionPerformed(evt);
        }
    }
    private void testCreateActionPerformed(ActionEvent e) {
        model.addRow(new Object[] {"New Name", Integer.valueOf(0), Boolean.FALSE});
        Rectangle rect = table.getCellRect(model.getRowCount()-1, 0, true);
        table.scrollRectToVisible(rect);
    }

    class DeleteAction extends AbstractAction{
        public DeleteAction(String label, Icon icon) {
            super(label,icon);
        }
        @Override public void actionPerformed(ActionEvent evt) {
            deleteActionPerformed(evt);
        }
    }
    public void deleteActionPerformed(ActionEvent evt) {
        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]));
        }
    }

    private class TablePopupMenu extends JPopupMenu {
        private final Action createAction = new TestCreateAction("add", null);
        private final Action deleteAction = new DeleteAction("delete", null);
        public TablePopupMenu() {
            super();
            add(createAction);
            addSeparator();
            add(deleteAction);
        }
        @Override public void show(Component c, int x, int y) {
            createAction.setEnabled(!check.isSelected());
            int[] l = table.getSelectedRows();
            deleteAction.setEnabled(l!=null && l.length>0);
            super.show(c, x, y);
        }
    }

    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);
    }
}

@@ -780,296 +780,462 @@
 ble)
-;%0A    private final JCheckBox check    = new JCheckBox(%22Disable Scrolling%22);%0A    public MainPanel() %7B%0A        super(new BorderLayout());%0A        TableColumn col = table.getColumnModel().getColumn(0
+ %7B%0A        @Override public void updateUI() %7B%0A            super.updateUI();%0A            JPopupMenu jpm = getComponentPopupMenu();%0A            if(jpm==null && pop!=null) %7B%0A                SwingUtilities.updateComponentTreeUI(pop);%0A            %7D%0A        %7D%0A    %7D;%0A    private final JCheckBox check    = new JCheckBox(%22Disable Scrolling%22);%0A    private final TablePopupMenu pop = new TablePopupMenu(
 );%0A    
-    col.setMinWidth(60);%0A        col.setMaxWidth(60);%0A        col.setResizable(false
+public MainPanel() %7B%0A        super(new BorderLayout()
 );%0A%0A
@@ -1266,16 +1266,28 @@
 0;i++) %7B
+%0A           
  model.a
@@ -1292,29 +1292,16 @@
 .addRow(
-%0A            
 new Obje
@@ -1353,16 +1353,24 @@
 FALSE%7D);
+%0A       
  %7D%0A%0A    
@@ -1503,88 +1503,259 @@
     
-JCheckBox box = (JCheckBox)ie.getSource();%0A                table.clearSelection(
+table.clearSelection();%0A                JScrollBar bar = scroll.getVerticalScrollBar();%0A                if(((JCheckBox)ie.getSource()).isSelected()) %7B%0A                    bar.setEnabled(false);%0A                    scroll.setWheelScrollingEnabled(false
 );%0A 
@@ -1773,39 +1773,98 @@
     
-boolean flag = !box.isSelected(
+    table.setEnabled(false);%0A                    //table.getTableHeader().setEnabled(false
 );%0A 
@@ -1882,56 +1882,77 @@
     
-JScrollBar bar = 
+    //
 scroll.
-getVerticalScrollBar();%0A
+setComponentPopupMenu(null);%0A                %7Delse%7B%0A    
     
@@ -1970,39 +1970,43 @@
  bar.setEnabled(
-flag);%0A
+true);%0A    
                 
@@ -2029,39 +2029,43 @@
 crollingEnabled(
-flag);%0A
+true);%0A    
                 
@@ -2085,12 +2085,12 @@
 led(
-flag
+true
 );%0A 
@@ -2096,34 +2096,32 @@
             
-%7D%0A
         
 %7D);%0A%0A       
@@ -2112,21 +2112,71 @@
     
-%7D);%0A%0A
+//table.getTableHeader().setEnabled(true);%0A            
         
 scro
@@ -2163,32 +2163,34 @@
                 
+//
 scroll.setCompon
@@ -2202,25 +2202,94 @@
 pupMenu(
-new Table
+pop);%0A                %7D%0A            %7D%0A        %7D);%0A%0A        scroll.setComponent
 PopupMen
@@ -2290,17 +2290,19 @@
 pupMenu(
-)
+pop
 );%0A     

Disable JTableHeader, JPopupMemu