可以幫我說明一下嗎?
程式碼是什麼意思呢
有一些不太懂
- class NumericTextLimit extends PlainDocument {
- private int limit;
-
- NumericTextLimit(int limit) {
- super();
- this.limit = limit;
- }
- public void insertString (int offset, String str, AttributeSet attr)
- throws BadLocationException
- {
- if (str == null) return;
- if ((getLength() + str.length()) <= limit) {
- //當輸入值合乎條件時才呼叫 super.insertString() 去改寫 Document 的 data.
- super.insertString(offset, str, attr);
- } else {
- getToolkit().beep();
- return;
- }
- }
- } // end of inner class NumericTextLimit
-
複製代碼 ... |