Guest User

Untitled

a guest
Aug 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. JTable: Select next cell on Tab, but first focus selects same cell, not next one
  2. add_button.addActionListener(new java.awt.event.ActionListener() {
  3. @Override
  4. public void actionPerformed(java.awt.event.ActionEvent evt) {
  5. int row = table_model.addRow();
  6. table.setRowSelectionInterval(row, row);
  7. table.scrollRectToVisible(table.getCellRect(row, 0, true));
  8. table.editCellAt(row, 0);
  9. table.transferFocus();
  10. did_add = true;
  11. }
  12. });
  13.  
  14. table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0, false), "selectNextColumnCell");
  15.  
  16. table.setRowSelectionInterval(row, row);
  17. table.setColumnSelectionInterval(0, 0);
Add Comment
Please, Sign In to add comment