?? mydocument.java
字號:
package com.wsy.util;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
public class MyDocument extends PlainDocument{
int maxLength =10;
public MyDocument(int newMaxLength){
super();
maxLength = newMaxLength;
}
public MyDocument(){
this(10);
}
//重載父類的insertString函數(shù)
public void insertString(int offset, String str, AttributeSet a)
throws BadLocationException {
if (getLength() + str.length() > maxLength) {//這里假定你的限制長度為10
return;
} else {
super.insertString(offset, str, a);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -