Bookmark Topic Watch Topic
  • New Topic

need help in applying inputverifer to jtextfield  RSS feed

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Report post to moderator

[b]1.facing problem in applying input verifier to JTextfield
[/b]

main class
VerifierTest




NotEmptyValidator.java





AbstractValidator -extended by NotEmptyValidator



interface



when i run the VerifierTest after compling all other files,i get the following error


VerifierTest.java:19: parent is not public in java.awt.Component; cannot be accessed from outside package
tf1.setInputVerifier(new NotEmptyValidator(parent, tf1, "Field cannot be null."));
^
VerifierTest.java:19: cannot find symbol
symbol : constructor NotEmptyValidator(java.awt.Container,javax.swing.JTextField,java.lang.String)
location: class NotEmptyValidator
tf1.setInputVerifier(new NotEmptyValidator(parent, tf1, "Field cannot be null."));
^
2 errors


can anyone correct the code .i have tried to change the call
tf1.setInputVerifier(new NotEmptyValidator(parent, tf1, "Field cannot be null."));

to

tf1.setInputVerifier(new NotEmptyValidator((JDialog)parent, tf1, "Field cannot be null."));

but still the error comes

i would be grateful if somebody removes this error as i need for my college project


and

2.i tried the following change


no optionPane or color of textfield changes
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please stick to your old thread. UseOneThreadPerQuestion. I've already shown you why it fails there - parent resolves to the private (or package default) field of java.awt.Component. You need to have a JDialog and use that as the first parameter.

Closing this thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!