我想开发一个计费系统swing应用程序,但是我在一个地方停留。我希望在账单后JTable行选择移到第一行进行下一次计费,但是在提交后的最后一个或其他行选择发生。请帮帮我... [KeyPressed事件后] 密钥绑定如下..
InputMap im = cartTable.getInputMap();
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Action.NextCell");
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "Action.NextCell");
ActionMap am = cartTable.getActionMap();
am.put("Action.NextCell", new AbstractAction(){
@Override
public void actionPerformed(ActionEvent e) {
int col = cartTable.getSelectedColumn();
int row = cartTable.getSelectedRow();
if(col==0 && cartTable.getValueAt(row, col)==null){
ProductListForm productList=new ProductListForm();
productList.setVisible(true);
}else if(col==1 && ProductListForm.product.getName()!=null){
setValueToTable();
}else if(col==7){
calculateValue();
}else if(col==9){
calculateTotal();
row++;
col=-1;
}
col++;
cartTable.changeSelection(row, col, false, false);
cartTable.editCellAt(row, col);
}
});
账单提交代码是这个..
if(evt.getKeyCode()==KeyEvent.VK_PAGE_DOWN){
JOptionPane.showMessageDialog(this, "Record Saved", "message", JOptionPane.OK_OPTION);
savePurchaseDetails();
saveStockDetails();
resetPage();
updateReturnTable();
int result=JOptionPane.showConfirmDialog(this, "Do you want to print reciept?", "Print Confirmation", JOptionPane.YES_NO_OPTION);
if(result==JOptionPane.YES_OPTION){
}
cartTable.changeSelection(0, 0, false, false);
}