0
我想刪除我的JTextPane
用戶鍵入的內容,我的意思是java如何刪除JTextPane的內容作爲用戶類型?
JTextPane.addKeyListener(new java.awt.event.KeyAdapter()
{
public void keyTyped(java.awt.event.KeyEvent evt)
{
searchFieldHandler(evt);
}
});
private void searchFieldHandler(java.awt.event.KeyEvent evt)
{
text = searchField.getText() + String.valueOf(evt.getKeyChar());
**searchField.setText("");**
// doing sth with text
}
,但它不工作(不刪除的內容,最後輸入的字符仍然是)怎麼辦?
1參見[*實現一個文獻濾波器*](http://docs.oracle.com/javase/tutorial /uiswing/components/generaltext.html#filter) – trashgod