mydocument.java
来自「一个贪吃蛇游戏」· Java 代码 · 共 33 行
JAVA
33 行
/**
* @(#)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 + =
减小字号Ctrl + -
显示快捷键?