• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

2 ComboBox's 1 Set

 
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I intend having a search where the user can search on two entitys in the database. eg-color and size, shape and sound, height and speed etc. I will provide this functionality through two combo boxs. When the app loads, ComboBox 1's default selection will be color. ComboBox 2's default selection will be size.

So combo box 1 should have all the possible values except the value selected in combobox 2 (color,shape,sound,height,speed)
and combo box 2 should have all the possible values except the value selected in combobox 1 (size,shape,sound,height,speed)

All works great so far!

Next, I add an item listener to combo box 1 saying "if a value is selected in combobox 2, remove that value from combobox 1's set and add the previously selected value of combobox 2, back into combo box 1's set of possible values."

Similarly, I add an item listener to combo box 2 saying "if a value is selected in combobox 1, remove that value from combobox 2's set and add the previously selected value of combobox 1, back into combo box 2's set of possible values."

This works superbly!

Until...

User selects their desired choice in combobox1 (combobox2's values immediatley update). The user then selects their desired choice in combobox2 (combobox1's values immediatley update ).

If you are still reading do you have any ideas?

Thanks,

G
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Glen Iris wrote:If you are still reading do you have any ideas?



excellent! Interestingly, I had already stopped reading when I saw this phrase!
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Glen Iris wrote:User selects their desired choice in combobox1 (combobox2's values immediatley update). The user then selects their desired choice in combobox2 (combobox1's values immediatley update )



Well champ, isn't it the effect that you wanted? I think I didn't get your problem quite well... the problem is that you wanted the selected option in combo box 1 to stay selected after selecting an option in combo box 2?

Other than that, which assignment is this one? Back in my days, there were no such options... I think I'm getting old
 
Glen Iris
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roberto Perillo wrote:

Glen Iris wrote:User selects their desired choice in combobox1 (combobox2's values immediatley update). The user then selects their desired choice in combobox2 (combobox1's values immediatley update )



the problem is that you wanted the selected option in combo box 1 to stay selected after selecting an option in combo box 2?(



Thats it in a nutshell Roberto. Its the bodgitt and scarper. The user must be able to search on the name, the location or both. I was trying to allow the user to search on any two db parameters. I guess Im over complicating it.

Any ideas on how to allow the user this functionality. I guess radio buttons, or two text fields (one for name, one for location).

G
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Glen Iris wrote:two text fields (one for name, one for location).


That's exactly what I did. One text field for name and another for location. If nothing is entered, all (valid) records are returned. If they fill both, all records with exactly matching name and location are returned. If they fill only one of the text fields, all records with exactly matching name or location are returned. Very easy to implement, easy to use and very intuitive for a user.
 
Glen Iris
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I was trying to be too clever for my own good. Thanks Roel.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never a good idea Always think KISS when developing an application It saved me already lots of time and many
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic