import javax.swing.table.DefaultTableModel;\r
\r
\r
-public class JListSortDialog extends JDialog {\r
+public class JListSortDialog extends JEscCancelDialog {\r
\r
private static final long serialVersionUID = 1L;\r
\r
private JPanel jpan = null;\r
private JButton jbtn_update = null;\r
private JButton jbtn_cancel = null;\r
+ private JButton jbtn_sort = null;\r
private JButton jbtn_remove = null;\r
private JButton jbtn_up = null;\r
private JButton jbtn_down = null;\r
int y = 10;\r
CommonSwingUtils.putComponentOn(jpan, getJScr_entries(), 400, 500, 10, y);\r
\r
+ CommonSwingUtils.putComponentOn(jpan, getJBtn_sort("ソート"), 100, 25, 10+400+10, y+500-(10+25)*8);\r
+ \r
CommonSwingUtils.putComponentOn(jpan, getJBtn_remove("削除"), 100, 25, 10+400+10, y+500-(10+25)*4);\r
\r
CommonSwingUtils.putComponentOn(jpan, getJBtn_up("上へ"), 100, 25, 10+400+10, y+500-(10+25)*2);\r
return jtbl_entries;\r
}\r
\r
+ // ソート\r
+ private JButton getJBtn_sort(String s) {\r
+ if (jbtn_sort == null) {\r
+ jbtn_sort = new JButton(s);\r
+ jbtn_sort.addActionListener(new ActionListener() {\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ ArrayList<String> tmpData = new ArrayList<String>();\r
+ for ( String data : rowData ) {\r
+ int index = 0;\r
+ for ( ; index<tmpData.size(); index++ ) {\r
+ String tmp = tmpData.get(index);\r
+ if ( tmp.compareTo(data) > 0 ) {\r
+ break;\r
+ }\r
+ }\r
+ tmpData.add(index,data);\r
+ }\r
+ \r
+ rowData.clear();\r
+ for ( String tmp : tmpData ) {\r
+ rowData.add(tmp);\r
+ }\r
+ \r
+ ((DefaultTableModel) jtbl_entries.getModel()).fireTableDataChanged();\r
+ }\r
+ });\r
+ }\r
+ return jbtn_sort;\r
+ }\r
+ \r
// 削除\r
private JButton getJBtn_remove(String s) {\r
if (jbtn_remove == null) {\r
jbtn_cancel.addActionListener(new ActionListener() {\r
@Override\r
public void actionPerformed(ActionEvent e) {\r
- reg = false;\r
- dispose();\r
+ doCancel();\r
}\r
});\r
}\r
return jbtn_cancel;\r
}\r
+ \r
+ @Override\r
+ protected void doCancel() {\r
+ reg = false;\r
+ dispose();\r
+ }\r
+ \r
}\r