Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Doumnet Listener Problem

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form with

One combox box
one text field
one search button

Search button is disabled initially and would be enabled only if text field has data and some data is selected from combo box

I am implementing DocumentListener and for text field I can check in
function insertUpdate(DocumentEvent arg0) and removeUpdate(DocumentEvent arg0) whether text field had data but I cant add combobox to document listener.

For adding document listener to text box I am using following code and its working fine
if (txt_customerName != null) {
txt_customerName.getDocument().addDocumentListener(this);
}

My question is that how oculd I add text box to this document listner or how could my program listen that combo box has got some data selected. I know I can use ItemListener but its not elegant

Kinu
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could install an InputVerifier on the JTextField and check the status of the JComboBox before you yield focus and enable the search button. You may need to have a member variable flag that is set by an appropriate listener on the JComboBox.
 
Kinu Kanwar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry. I am not too proficient in swing , could you please explain more your suggestion or some code ??

Kinu
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic