私は
ことをやりたい、シリアル番号が順次自体によって再オーダーになるだろう。.. .serialない列は例えばテーブルビューitself..inによって並べ替えないであろう..と仮定デアフィールド名(として5行である:Sr.noとしてF1:2と1、F2、F3 3、F4として4として、F5は5)f1が下のボタンをクリックすると第2位に移動すると、f1 srnoは2なり、f2は、セルをシフトした後、動的1あろう..
またはボタンアップのクリックに上向きの位置へF5移動した場合、次にF5用srno 4およびF4 srnoが5になるとなる..
親切に私に論理を教えてください。
私のコード:
ReadOnlyIntegerProperty selectedIndex = tableupdateSpacee.getSelectionModel().selectedIndexProperty();
upaction.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent evt) {
int index = tableupdateSpacee.getSelectionModel().getSelectedIndex();
// swap items
tableupdateSpacee.getItems().add(index-1, tableupdateSpacee.getItems().remove(index));
// select item at new position
tableupdateSpacee.getSelectionModel().clearAndSelect(index-1);
int a=colFieldSrno.getCellData(index);
colFieldSrno.setCellValueFactory(new PropertyValueFactory<>("srno"));
System.out.println("col serial number"+colFieldSrno.getCellData(index));
// tableupdateSpacee.getColumns().add(colFieldSrno.getCellData(index));
tableupdateSpacee.setItems(modelUpdateSpace);
tableupdateSpacee.refresh();
}
});
downaction.setOnAction(evt -> {
int index = tableupdateSpacee.getSelectionModel().getSelectedIndex();
// swap items
tableupdateSpacee.getItems().add(index+1, tableupdateSpacee.getItems().remove(index));
// select item at new position
tableupdateSpacee.getSelectionModel().clearAndSelect(index+1);
tableupdateSpacee.refresh();
});
'srNo'カラムに'(index + 1) 'と表示させたいのですが' index'は行番号ですか? –
はい、私は行を下向きの位置に移動するとインデックス+1になり、上向きの位置についてはインデックス-1になります。 –
あなたがそれを移動するとインデックスが変わると思いますので、 + 1 '、いいえ?ここには本当に財産は必要ありません。 –