// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.event.ActionListener;
import java.util.stream.Stream;
import javax.swing.*;
import javax.swing.plaf.IconUIResource;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

public final 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}
  };
  private final TableModel 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 transient RowSorter<? extends TableModel> sorter = new TableRowSorter<>(model);

  private static final Icon EMPTY_ICON = new EmptyIcon();
  private final Icon customAscendingSortIcon = new ImageIcon(getClass().getResource("ascending.png"));
  private final Icon customDescendingSortIcon = new ImageIcon(getClass().getResource("descending.png"));

  private final JButton clearButton = new JButton("clear SortKeys");

  private Box makeRadioPane() {
    JRadioButton r0 = new JRadioButton("Default", true);
    JRadioButton r1 = new JRadioButton("Empty");
    JRadioButton r2 = new JRadioButton("Cumstom");
    ActionListener al = e -> {
      JRadioButton r = (JRadioButton) e.getSource();
      Icon ascending = null;
      Icon descending = null;
      if (r.equals(r0)) {
        ascending = UIManager.getLookAndFeelDefaults().getIcon("Table.ascendingSortIcon");
        descending = UIManager.getLookAndFeelDefaults().getIcon("Table.descendingSortIcon");
      } else if (r.equals(r1)) {
        ascending = new IconUIResource(EMPTY_ICON);
        descending = new IconUIResource(EMPTY_ICON);
      } else {
        ascending = new IconUIResource(customAscendingSortIcon);
        descending = new IconUIResource(customDescendingSortIcon);
      }
      UIManager.put("Table.ascendingSortIcon", ascending);
      UIManager.put("Table.descendingSortIcon", descending);
      table.getTableHeader().repaint();
    };
    Box box1 = Box.createHorizontalBox();
    box1.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    ButtonGroup bg = new ButtonGroup();
    box1.add(new JLabel("Table Sort Icon: "));
    Stream.of(r0, r1, r2).forEach(rb -> {
      box1.add(rb);
      box1.add(Box.createHorizontalStrut(5));
      bg.add(rb);
      rb.addActionListener(al);
    });
    box1.add(Box.createHorizontalGlue());
    return box1;
  }

  public MainPanel() {
    super(new BorderLayout());
    table.setRowSorter(sorter);
    clearButton.addActionListener(e -> sorter.setSortKeys(null));

    add(makeRadioPane(), BorderLayout.NORTH);
    add(clearButton, BorderLayout.SOUTH);
    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
    }
    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 EmptyIcon implements Icon {
  @Override public void paintIcon(Component c, Graphics g, int x, int y) {
    /* Empty icon */
  }

  @Override public int getIconWidth() {
    return 0;
  }

  @Override public int getIconHeight() {
    return 0;
  }
}

@@ -1224,78 +1224,8 @@
 );%0A%0A
-  private final JButton clearButton = new JButton(%22clear SortKeys%22);%0A%0A
   pr
@@ -1248,24 +1248,24 @@
 dioPane() %7B%0A
+
     JRadioBu
@@ -1400,17 +1400,16 @@
 tton(%22Cu
-m
 stom%22);%0A
@@ -1504,39 +1504,32 @@
   Icon ascending
- = null
 ;%0A      Icon des
@@ -1539,15 +1539,8 @@
 ding
- = null
 ;%0A  
@@ -2634,21 +2634,22 @@
   %7D%0A%0A  p
-ublic
+rivate
  MainPan
@@ -2717,16 +2717,74 @@
 sorter);
+%0A%0A    JButton clearButton = new JButton(%22clear SortKeys%22);
 %0A    cle

fix typo Cumstom should be Custom