Olá galera.
To tentando compilar a minha classe FixaTamanho.java e da o seguinte erro:
[quote]symbol : method insertString(int,java.lang.String,javax.print.attribute.AttributeSet)
location: class javax.swing.text.PlainDocument
super.insertString(offset, str, attr);
[/quote]
Aki ta o fonte:
/*
* FixaTamanho.java
*
* Created on 1 de Agosto de 2007, 08:06
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package Package;
import javax.print.attribute.AttributeSet;
import javax.swing.text.*;
/**
*
* @author Hanjo_
*/
public class FixaTamanho extends PlainDocument {
private int iMaxLength;
public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
if (str == null) return;
if (iMaxLength <= 0) { // aceitara qualquer no. de caracteres
super.insertString(offset, str, attr);
return;
}
int ilen = (getLength() + str.length());
if (ilen <= iMaxLength) // se o comprimento final for menor...
super.insertString(offset, str, attr); // ...aceita str
else {
if (getLength() == iMaxLength) return; // nada a fazer
String newStr = str.substring(0, (iMaxLength - getLength()));
super.insertString(offset, newStr, attr);
}
}
}
fonte pego aki no guj mesmo!
Obs: pode ser bug do netbeans?