Document 类用来管理文本组件中的数据。 每一个文本组件都对应的有document 具体的可以查看javax.swing.text.JTextComponent类中的介绍 调用public Document getDocument()可以得到Document Document类有一个方法:public void addDocumentListener(DocumentListener listener 每当文本组件中的内容变化的时候 都将将事件传输给listener来处理。具体来说定义了下列三个方法 void changedUpdate(DocumentEvent e) Gives notification that an attribute or set of attributes changed. void insertUpdate(DocumentEvent e) Gives notification that there was an insert into the document. void removeUpdate(DocumentEvent e) Gives notification that a portion of the document has been removed. 其中e是事件 e有方法: Document getDocument() Gets the document that sourced the change event. int getLength() Returns the length of the change. 可以得到相关的信息 而Document 类有String getText(int offset, int length) 返回刚才键入的string
是Panel吗?
他有社么方法来处理词组输入呢?你能描述的详细写吗
e.getKeyCode()咋return String?
每一个文本组件都对应的有document
具体的可以查看javax.swing.text.JTextComponent类中的介绍
调用public Document getDocument()可以得到Document
Document类有一个方法:public void addDocumentListener(DocumentListener listener 每当文本组件中的内容变化的时候
都将将事件传输给listener来处理。具体来说定义了下列三个方法
void changedUpdate(DocumentEvent e)
Gives notification that an attribute or set of attributes changed.
void insertUpdate(DocumentEvent e)
Gives notification that there was an insert into the document.
void removeUpdate(DocumentEvent e)
Gives notification that a portion of the document has been removed. 其中e是事件
e有方法:
Document getDocument()
Gets the document that sourced the change event.
int getLength()
Returns the length of the change.
可以得到相关的信息
而Document 类有String getText(int offset, int length) 返回刚才键入的string
可能我没有说清楚:
我是在一个Panel上实现基本中文编辑器的功能。而不是在文本组件上处理输入字串。
不管如何,我会放分的。
或者javax.swing.JEditorPane
Del事件吗?
好象它没用JTextPane和JEditorPane作编辑器的主体.不过它可以输入任意的词汇.
看看先.