Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

need help in applying inputverifer to jtextfield

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome 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
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!