• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to correct failing ComboBoxListViewSkin when reinitialized within same application instance?

 
Ranch Hand
Posts: 61
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem:
The ComboBoxListViewSkin class implementation fails within my ComboBoxAutoComplete class constructor when it has to be reinitialized because of updated ComboBox database data. The ComboBoxListViewSkin class is only being used to allow the user to enter a [SPACE] in the auto-completion search through the skin. This also prevents the [SPACE] from selecting and closing the ComboBox List (expected and wanted). It's a nice feature. This functionality works great when the application is first opened with the user default database, but if that database is updated or a new database opened, it requires this ComboBox to be updated and the AutoCompletion reinitialized.

This is a custom AutoCompletion class because this is being performed on 'uneditable' ComboBoxes (combobox.setEditable(false)). ControlsFX does not have this ability except on "editable" ComboBoxes.

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.scene.control.skin.ComboBoxListViewSkin.getEditor(ComboBoxListViewSkin.java:189)


The code within the constructor:
The cbSkin could probably be a local variable. I declared it private outside the constructor because it seemed to impact whether the 'carrot' in the upper left corner of the ComboBox was visible or not.



What is expected:
The capability of the ComboBox to retain original initialized functionality when updating or switching between databases, which allow the ability to use a [SPACE-KEY] when searching on topics in a ComboBox.

What I have tried:
I've tried using various if statements either prior to, or wrapped around this functionality in the constructor in an attempt to reinitialize it, or to simply remove and apply a new skin (cmb.setSkin()). But nothing seems to work. I have thought about and tried initializing the  ComboBoxListViewSkin outside the ComboBoxAutoCompletion class, but I don't think that is possible. When I pass the ComboBox to the class, I don't see a way of setting up the getPopupContent().addEventFilter from the ComboBox being passed. I tried through the cmb.getSkin(), but with no success. Secondly, the getPopupContent().addEventFilter has the lamda calls referencing the encapsulated variable 'filter', which retains the characters and [SPACE] during the user interaction.

Lastly, I receive the 'carrot' in the upper left corner of the ComboBox (see image) when the second initialization is attempted; which I had before until I added "cmb.setSkin(cbSkin)" and it went away. However, this is back now. A minor issue, more aesthetic, but I'm hoping will disappear if I can figure out with some help how to solve this problem.

What I'm doing here isn't common on an uneditable ComboBox, and custom in that respect.  Even though searched I didn't find anything except what I had posted as a resolution to this issue if you only needed a single instance on SuperUser/StackOverflow... and wanted to remove the 'carrot'.



 
Scott Vallery
Ranch Hand
Posts: 61
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought this was attached... it may or may not help visually.

options-first-database.JPG
[Thumbnail for options-first-database.JPG]
Example expected functionality after ComboBox is updated... currently Skin functionality fails on update
 
Scott Vallery
Ranch Hand
Posts: 61
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved my issue and the solution was stupidly obvious. I simply only needed to initialize my ComboBoxAutoCompletion once and just pass the updated list for each update or databaase change. To demonstrate I used a boolean to track the first initialization. For some odd reason the caret is appearing in the upper left corner of the box now. Previously, adding the "this.cmb.setSkin(cbSkin)" caused this to disappear. I consider this issue post solved since core functionality works.

Global declaration:


Solution:


Minor constructor update with public ObservableList for updating:
 
Sheriff
Posts: 6030
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting the solution back to the forum!
 
Scott Vallery
Ranch Hand
Posts: 61
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NP Sheriff! I did solve the carrot problem... I missed a duplicate initialization during testing.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!