📄 mydocument.java
字号:
/**
* @(#)MyDocument.java
* @A document used to limiting the length of the input text.
*
* @Link Scholes
* @version 1.00 2008/7/21
*/
package GUI;
//Java extension packages
import javax.swing.text.*;
public class MyDocument extends PlainDocument
{
private int length;
//construct a document with specified length limit of the input text
public MyDocument(int n)
{
super();
length = n;
}
//limit the input
public void insertString(int offs,String str,AttributeSet a) throws BadLocationException
{
if(getLength() + str.length() < length + 1)
{
super.insertString(offs,str,a);
}
}
} //end class MyDocument
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -