日期:2014-05-20  浏览次数:20734 次

救救我的记事本啊!
我用JAVA写了个简单的记事本大家谁能说说怎么判断JTextArea中的内容是否发生了改变呢

------解决方案--------------------
change事件
------解决方案--------------------
添加一个ActionListener
------解决方案--------------------
The java.awt.TextArea could be monitored for changes by adding a TextListener for TextEvents. In the JTextComponent based components, changes are broadcasted from the model via a DocumentEvent to DocumentListeners. The DocumentEvent gives the location of the change and the kind of change if desired. The code fragment might look something like:

DocumentListener myListener = ??;
JTextArea myArea = ??;
myArea.getDocument().addDocumentListener(myListener);

api 原文

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JTextArea.html
------解决方案--------------------
增加定时自动保存
------解决方案--------------------
JTextArea的父类(应该是JTextComponent如果没记错的话)直接有copy(),cut(),paste()