• Post Reply 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

text filed and button validation

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is ramesh kancherla. I am creating a swing frame.in my swing frame buttons and text fields are there.

one button name addEmail is link to one text field.
when entering text into text field addEmail button will enable.
when removing text from textfield by backspace or delete key or any other way
after removed text from textfield if it is empty then addEmail button will go to disable mode.

i am checking with text field empty or not when key is pressed.
But disable mode and enable mode is not properly working.

can any one please give me an idea how do I implement it.

Thanks & Regards
Ramesh k
 
Marshal
Posts: 79928
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try adding Listeners to your text fields, but that doesn't sound at all like good programming to me. Nor does enabling and disabling buttons depending on whether text is being added or deleted sound good to me.

If you have an empty text field, or text which doesn't match an e-mail address (do a search through JavaRanch for regular expressions for e-mail addresses, which can be very long), you have various options from your button:
  • Throw Exception.
  • Pop up JOptionPane.
  • Delete text.
  •  
    Ranch Hand
    Posts: 62
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You have action listeners (button events, etc...) as well as key listeners (where you can take certain actions on various key strokes) as well as others.

    Give us more of you requirements and someone can assist perhaps?
     
    Ranch Hand
    Posts: 4632
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
     
    ramesh kancherla
    Ranch Hand
    Posts: 124
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for your help.it is working fine
     
    A day job? In an office? My worst nightmare! Comfort me tiny ad!
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic