I have two classes
public class Finestra extends javax.swing.JFrame{
........
jtextField.setinputVerifier(.....):
}
public abstract class Verifica extends InputVerifier{
String message;
public Verifica(String message){
}
public abstract boolean verifica(JtextField c);
public boolean verify(Jcomponent c){
JTextField c = (JTextField) jc;
if (esito(c) == false){
return false;
}else{
return true;
}
}
}
}
I want to use Verifca class in finestra. I don't extends it because there is javax.swing.JFrame. Can i do to use Verifica? and is it a problem the only abstract method verifica.
I try this, but doesn' work
testo.setInputVerifier(new Verifica("error") {
public boolean verifica(testo){
if (testo.getText == null){
return true;
}else{
return false;
}
}
});
What you're trying to do is to have an abstract class
Verificaand then, when using it, to create an anonymous class with a custom implementation of the methodverifica.In the anonymous class definition that you're doing, you must override the variable with the same signature like this for example:
You cannot "bind" your variable
testoas the parameter for yourverificamethod in the anonymous class. You can, however, refer totestodirectly from the outside scope of you anonymous class (so it gets bound in the implementation, not the signature of the method), resulting in something like this:and