Thursday, 15 March 2012

java - Creating A JTextField Input Validator -


I'm trying to create a JTextField input verifier. I'm starting to have all sections on the page and now I try to use NotEmptyValidator . I have a JFrame and a JTextField . I am trying to use this package, but it is giving me an error. The code is shown below:

  public class Manytm Jfram extension {public JTextField field; Public Valid () {this.field = New JTextField (); This.field.setInputVerifier (new NotEmptyValidator (this, this.field, "no empty value")); // shows an error line this.setTitle ("ValidateTest"); This.setVisible (true); This.setSize (200, 200); This.setLayout (new border layout ()); This.add (this.field, BorderLayout.NORTH); } Public static void (String [] args) {try to {(LookAndFeelInfo information: UIManager.getInstalledLookAndFeels ()) {if ( "Nimbus" .equals (info.getName ())) {UIManager.setLookAndFeel (info.getClassName ( )); break; }}} Hold (exception e) {} valid vt = new valid test (); }}  

Note: I have taken classes now because they are. I with JTextField and String provided but how JDialog does not know how to do it.

  1. How do we fix this error and went wrong here?

Well I NotEmptyValidator The following have to producers in the classroom Managed to solve the problem by doing so. I found the following:

  this.field.setInputVerifier (New NotEmptyValidator (New JDialog (this), this.field, "No empty value");  

No comments:

Post a Comment