aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Doumnet Listener Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Doumnet Listener Problem" Watch "Doumnet Listener Problem" New topic
Author

Doumnet Listener Problem

Kinu Kanwar
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
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
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
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

Joined: Apr 19, 2005
Posts: 33
I am sorry. I am not too proficient in swing , could you please explain more your suggestion or some code ??

Kinu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doumnet Listener Problem