Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: a very strange situation about ItemEvent

 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meet a stange question:
First I have a nameCheckBox , a nameJTextField and a locationCheckBox , a locationJTextField and a JComboBox include two items 'and' , 'or' .
Second I write a JTFieldFocusListener implements FocusListener and
a CheckBoxListener implements ItemListener;
Third I made :
nameBox.addItemListener(myBListener);
locationBox.addItemListener(myBListener);
nameField.addFocusListener(myJTFocusListener);
locationField.addFocusListener(myJTFocusListener);
At last , when nameBox was selected , nameField was setEditable;
when locationBox was selected , locationField was setEditable.
But When I run , I cann't set mouse to focus into nameField or loactionField once I change item of JComboBox. I only can put mouse out of
the GUI and put into the GUI again , then I can put mouse into field again.
Why ? can anyone help me ?
Thanks very much! please quick!
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steven,
Originally posted by steven Gu:
I meet a stange question:
First I have a nameCheckBox , a nameJTextField and a locationCheckBox , a locationJTextField and a JComboBox include two items 'and' , 'or' .
Second I write a JTFieldFocusListener implements FocusListener and
a CheckBoxListener implements ItemListener;
Third I made :
nameBox.addItemListener(myBListener);
locationBox.addItemListener(myBListener);
nameField.addFocusListener(myJTFocusListener);
locationField.addFocusListener(myJTFocusListener);
At last , when nameBox was selected , nameField was setEditable;
when locationBox was selected , locationField was setEditable.
But When I run , I cann't set mouse to focus into nameField or loactionField once I change item of JComboBox. I only can put mouse out of
the GUI and put into the GUI again , then I can put mouse into field again.
Why ? can anyone help me ?
Thanks very much! please quick!

Sorry, I don't know how to solve your focus problem.
However, I'd like to make a comment about your GUI: are the nameCheckBox and the LocationCheckBox really necessary? I understand the reason for the and/or JComboBox (although I have a comment to make about that later). But the other two checkBoxes seem unncessary to me.
Let's consider 4 cases:

1) would return all the records, that is, all the records having any name AND all the records having any location.
2) would return all the records having name="Dog and Son" AND having any location.
3) would return all the records having name="Dog and Son" AND having location="Hooterville".
4) would return all the records having name="Dog and Son" OR having location="Hooterville".
The first 3 queries seem very reasonable: the first simply wants to see all the records, the second wants to see all the entries for Dog and Son, the third wants to see all the records where Dog and Son is located in Hooterville.
The fourth query seems a little strange: the user wants to see all the records for Dog and Son plus all the records located in Hooterville.
Because of the strangeness of the fourth query I think most people are not supporting it for their project. Also, if you feel it is a legitimate query then it could be supported by doing two independent queries. First query for all the records having "Dog and Son", look at those records. Then query for all the records located in "Hooterville", look at those records.
If you accept that it is not really necessary to support the fourth query then the need for the AND/OR combo box disappears.
So you could if you agree with the above reasoning eliminate the three check boxes. That might make you focus problem disappear as well.
Finally, you might want to switch from text fields to combo boxes and allow the user to access a drop-down list of names and locations to make entering the search criteria easier.
 
steven Gu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First Thanks George Marinkovich
Last night , I changed my GUI solution . I use JRadioButton instead of JComBox. And that's ok!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic