Reputation: 109
I have this code:
public class Anagrafica implments ClientiInterface{
InputVerifier verifierAliquotaIva = new InputVerifier() {
public boolean verify(JComponent input) {
boolean verifica = true;
final JTextComponent source = (JTextComponent) input;
String text = source.getText();
if (text.length() != 0){
String codice = cliente.CercaCliente(text, this);
if (codice != null){
verifica = true;
}else{
JOptionPane.showMessageDialog(null, "Codice iva inesistente!");
tfDescrizioneIva.setText("");
verifica = false;
}
}else{
tfDescrizioneIva.setText("");
}
return verifica;
}
};
}
This is an Clientiinterface. I saw that interface is incompatible within InputVerifier
. How can I resolve this problem?
Upvotes: 0
Views: 81
Reputation: 445
If I understood correctly of what you are trying to achieve, you must use the following:
public class MyInputVerifier implements InputVerifier { ... }
instead of this:
InputVerifier verifierAliquotaIva = new InputVerifier() { ... }
and then use new MyInputVerifier()
where needed.
More scientifically, an interface is only a skeleton, it has no implementation. If you want custom code in a place where InputVerifier
is required, create a class that implements it, and use an instance of your new class
Upvotes: 2