JTextField
NECESITO VALIDAR UN JTEXTFIELD A LETRAS MAYUSCULAS DE MANERA QUE CUANDO DIGITE UN CARACTER SI ESTA EN MINUSCULA EL ME LO TRANSFORME A MAYUSCULA.
NOTA:
ES TRANSFORMAR EL CARACTER DIGITADO A MAYUSCULA NO CAPTUTAR EL STRING Y PASARLO A MAYUSCULA
MUCHAS GRACIAS!
NOTA:
ES TRANSFORMAR EL CARACTER DIGITADO A MAYUSCULA NO CAPTUTAR EL STRING Y PASARLO A MAYUSCULA
MUCHAS GRACIAS!
Hazte una clase que herede de PlainDocument.
En ella, redefine el metodo insertString()
La redefinicion de este método debe pasar a mayúsculas el String que se le pasa y luego llamar al super.insertString (...)
class MiPlainDocument extends PlainDocument
{
void insertString(int offs, String str, AttributeSet a)
{
super.inserString (offs, str.toUpperCase(), a);
}
}
Una vez hecho esto, a tu JTextField llama al metodo setDocument() y pasale una instancia de la clase anterior.
textField.setDocument (new MiPlainDocument());
Se bueno.
En ella, redefine el metodo insertString()
La redefinicion de este método debe pasar a mayúsculas el String que se le pasa y luego llamar al super.insertString (...)
class MiPlainDocument extends PlainDocument
{
void insertString(int offs, String str, AttributeSet a)
{
super.inserString (offs, str.toUpperCase(), a);
}
}
Una vez hecho esto, a tu JTextField llama al metodo setDocument() y pasale una instancia de la clase anterior.
textField.setDocument (new MiPlainDocument());
Se bueno.
