• 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

JavaFX ObservableList and brackets

 
Ranch Hand
Posts: 147
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
QUESTION:
===========

Why does observableArrayList put square brackets around values ?
I can subsrting into them to get rid of them, BUT, it shouldn't be so.

Also, I have this error message when I tried to cast ObservableList<String> to String just so I can set the value.
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: com.sun.javafx.collections.ObservableListWrapper cannot be cast to javafx.beans.property.SimpleStringProperty

DETAIL
===========

When overlaying my old Java codes with JavaFX, I found it necessary to use ObservableArrayList throughout all scenes to access the data retrieved from cloud, lke this:


The data coming back from the db are in JSON string which I can easily unpack. For example
userName = Arthur Chan

But when I access the ObservableList<String> userName from annother scene or class, it has square brackets around them, like this:
userName = [Arthur Chan]

I can get rid of the brackets, but I shouldn't have to b/c there's no reason why JavaFX should wrap in brackets..


 
Sheriff
Posts: 6029
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that an ObservableList is still a List, so you will have to use userName.get(0) to get the first element in the List.
 
AhFai Chan
Ranch Hand
Posts: 147
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gotcha
Onto next FX challenge...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!