Witam.
Mam stworzony JTable z własnym modelem.
import javax.swing.table.AbstractTableModel;
public class MyTableModel extends AbstractTableModel{
private Object[][] data;
private int column;
public MyTableModel(){
...
}
public int getRowCount() {
...
}
public int getColumnCount() {
...
}
public Object getValueAt(int row, int col) {
...
}
public boolean isCellEditable(int row, int col) {
...
}
public void setValueAt(Object value, int row, int col) {
...
}
public void addRow(Object[] row) {
...
}
public void delRow(int row){
...
}
public String getColumnName(int column) {
...
}
public void wyczysc(){
...
}
public Class getColumnClass(int c) {
...
}
}
a w klasie gdzie tworze tabele daje
model = new MyTableModel();
sorter = new TableRowSorter<MyTableModel>(model);
Problem jest taki, że mając
cyfry 1,2,3,6,7,10,11 to po sortowaniu mam 1,10,11,2,3,6,7
majac dane 1d,2d,3,4d,10d,11d po sortowaniu mam 10d,11d,1d,2d,3d,4d
dane textowe sortuje alfabetycznie.
Odnosnie danych 1d,2d,11d,10d,3d chciałbym aby przy sortowaniu bralo pod uwage tylko liczby, czyli zeby wynik wyglądał: 1d,2d,3d,10d,11d
Podejrzewam, ze trzeba jakos zaznaczyc, ze ma sortowac jaki liczby a nie stringi, ale nie za bardzo wiem jak.