• 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

ComboBox field empties upon changing selection however value is not null

 
Ranch Hand
Posts: 271
6
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, so basically I have multiple combo boxes which are filled with data pulled from MySQL database
However, there is this type of box where when I change selection the text disappears
I tested to see if the value changes to null because the field is empty however the value returned is always the selected item and everything works fine so it seems to me like a bug however I thought I should still ask for help because I am probably looking at it wrong

This is how I populate my ComboBox


I have multiple other ComboBox which store types other than Suppliers and they all work fine, they all use the same filteredComboBoxManager method as well however each has it's own setComboBoxConvertor.

Thank you again in advance
 
Yosuf Ibrahim
Ranch Hand
Posts: 271
6
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still stuck on this guys
 
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FX_Utilities.filteredComboBoxManager() - no code, not sure what this is doing.

Is this "Supplier" the standard Java functional interface Supplier, or your own type? You probably want to use a type of your own as your ComboBox item type, and implement toString(); it could implement the Supplier interface too, if useful. Also/or this might be fixed by setting a cell factory on the ComboBox. Basically the CB needs to know how to render the items it's listing - that's not always "free" functionality.

If you want a for-certain answer you may need to add a complete example starting from something like this so we can see exactly what you're seeing:



I have multiple other ComboBox which store types other than Suppliers and they all work fine



Might have started to answer your own question there.
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yosuf Ibrahim wrote:I am still stuck on this guys



Yeah not sure where the other ranchers are lately. Usually some of the others will pop into this remote frontier JavaFX ranch to see if I'm still alive living all alone out here. Sometimes the native code tribes get restless and come around looking for trouble... angry folk, they all still use C and C++. Guess I can't blame them with us VM-based ranchers moving in on their territory...
 
Yosuf Ibrahim
Ranch Hand
Posts: 271
6
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lou Hamers wrote:FX_Utilities.filteredComboBoxManager() - no code, not sure what this is doing.


Yeah lol sorry, there you go, I took this function from stack overflow to allow for filtering my combo box result as the user is typing in. I edited a small chunk of it a long time ago but I do not even remember what is in there, it works perfectly though


Lou Hamers wrote:
Is this "Supplier" the standard Java functional interface Supplier, or your own type? You probably want to use a type of your own as your Combo Box item type, and implement toString(); it could implement the Supplier interface too, if useful. Also/or this might be fixed by setting a cell factory on the Combo Box. Basically the CB needs to know how to render the items it's listing - that's not always "free" functionality.

If you want a for-certain answer you may need to add a complete example starting from something like this so we can see exactly what you're seeing:

I have multiple other ComboBox which store types other than Suppliers and they all work fine



Might have started to answer your own question there.



Supplier class is not the standard java, it is my own. I tried to recreate a complete example of what is happening in a separate project but I am not getting the same error anymore which is even more confusing since all I did different is instead of pulling the Supplier from the database I created them in the Main class, which probably means there is something else. I will try to read from the database in my temp project as well and see if I get the same results or not

 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lou Hamers wrote:

Yosuf Ibrahim wrote:I am still stuck on this guys



Yeah not sure where the other ranchers are lately. Usually some of the others will pop into this remote frontier JavaFX ranch to see if I'm still alive living all alone out here. Sometimes the native code tribes get restless and come around looking for trouble... angry folk, they all still use C and C++. Guess I can't blame them with us VM-based ranchers moving in on their territory...



Actually, it's more to do with the fact that we don't get paid to do this, so we check in when we aren't otherwise doing our full-time jobs, home maintenance, watching TV or whatever. The Ranch is not the place to come for "instant answers". To get that level of service costs money.

So yes, I spent the last 4 hours elsewhere, doing yard maintenance before the next killer heatwave sets in, corresponding with a client, and eating more than I should.

Also, in my case, I've never worked with JavaFX. so any advice I give here is necessarily general in nature. JavaFX doesn't have a lot of support at the moment, though,

As far as general advice goes, however, that code smells to me like it's trying to do too much. In most GUI systems, a lot of those things would be automatically done by the GUI framework itself. So it's possible that simplifying the code might actually make it work better.
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Haha, yeah I know Tim, I'm no different (other than having the uncommon JFX background I guess).
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yosuf Ibrahim wrote:
Supplier class is not the standard java, it is my own. I tried to recreate a complete example of what is happening in a separate project but I am not getting the same error anymore which is even more confusing since all I did different is instead of pulling the Supplier from the database I created them in the Main class, which probably means there is something else. I will try to read from the database in my temp project as well and see if I get the same results or not



Aha, it sounds like you're on the trail of the problem then. That's one of the nice things about this technique of reproducing the problem in a smaller example. Every so often the code you think SHOULD reproduce it doesn't, which tells you that the problem is somewhere you haven't been looking. Usually shortly after that happens you find the problem yourself without posting the question publicly.

Maybe whatever you think is coming from the database/datasource is not what you're expecting?
 
Yosuf Ibrahim
Ranch Hand
Posts: 271
6
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow I got stuck with trying to get an event handler that only gets fired when a selection has been made and somehow Google brought me back here :P

My post is famous.
 
Yosuf Ibrahim
Ranch Hand
Posts: 271
6
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow I got stuck with trying to get an event handler that only gets fired when a selection has been made and somehow Google brought me back here :P

My post is famous.
 
There is no greater crime than stealing somebody's best friend. I miss you 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