기본적인 접근 방식은 현재 셀에 대해 확인하는 사용자 지정 작업에 테이블의 기본 탐색 작업을 래핑하는 것입니다 ... 미리 감사합니다 : 그것은 마지막 있다면, 할 기본 동작을 재사용하기위한
Object key = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.get(KeyStroke.getKeyStroke("ENTER"));
final Action action = table.getActionMap().get(key);
Action custom = new AbstractAction("wrap") {
@Override
public void actionPerformed(ActionEvent e) {
// implement your prevention logic
// here: don't perform if the current cell focus is the very cell of the table
int row = table.getSelectionModel().getLeadSelectionIndex();
if (row == table.getRowCount() - 1) {
int column = table.getColumnModel().getSelectionModel().getLeadSelectionIndex();
if (column == table.getColumnCount() -1) {
// if so, do nothing and return
return;
}
}
// if not, call the original action
action.actionPerformed(e);
}
};
table.getActionMap().put(key, custom);
+1 : 아무것도 그렇지 않으면 포장 작업을
코드 예제를 실행하지 않습니다. – camickr