我已经实现了一个keylistener:
txtAddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent e) {
System.out.println("keyPressed " + e.getKeyCode() + " delete " + KeyEvent.VK_DELETE + " backspace " + KeyEvent.VK_BACK_SPACE);
if (e.getKeyCode() == KeyEvent.VK_DELETE || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
StringSelection theValue = new StringSelection(txtAddress.getText());
deleteSubscriber(theValue);
}
}
});
我需要获取已删除的文本进行处理。 theValue是字段的当前文本,而不是要删除的选定文本。