java


How to listen to changes made on javafx choicebox


I have a custom ChoiceBox which I am filling dynamically like so:
public class CustomChoiceBox {
public void addItems(List<Item> items) {
// Populate choicebox
for(Item item : items) {
CustomOption choice = new CustomOption(String.valueOf(item.getId()), item);
this.getItems().add(choice);
}
}
}
CustomOption is a custom class defined as below:
public class CustomOption extends Observable{
private String key;
private Object value;
public CustomOption(String key, Object value) {
this.key = key;
this.value = value;
}
}
I want to be able to listen to when the user makes a different choice and to get the value of that choice.
So I have added a listener :
myChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CustomOption>() {
#Override
public void changed(ObservableValue<? extends CustomOption> observable,
CustomOption oldValue, CustomOption newValue) {
System.out.println(newVaue.getValue());
}
});
However this code is not running when I change the choices.
I have also tried using myChoiceBox.valueProperty()

Related Links

Jar file in package is not a file or directory
connect facebook, twitter and google in a single activity android onActivityResult Error
log4j creating .tmp file for logs randomly
AOP type annotation based logging - java implementation without using Spring
Does spring internally uses servlets? [duplicate]
Fortify security issue “Unreleased resource stream”
Read .m4a Tags on Android
Spring-security : session-config with COOKIE not working
Elasticsearch transport client java client
How to pass an extra parameter with spring security login form?
HttpClientErrorException: 400 Bad Request while searching in elastic search using spring restemplate
How to Display BarChart Dynamically using Spring
How to call inner class of fragment from activity
Painters odd behavior
CandleStickChart add only one entry
Providing same dates in JPA criteria API not returning result

Categories

HOME
winforms
date
keras
relay
read-eval-print-loop
youtube-dl
at-command
v8
fsm
ckeditor
ebean
yum
datastax-java-driver
contact
medical
volttron
kentor-authservices
spring-xd
export-to-csv
etl
size
django-simple-history
progressive-web-apps
google-static-maps
google-cloud-speech
google-pagespeed
lldb
amazonsellercentral
paging
scriptcs
sqlcipher
smb
numerical-methods
pepper
status
maxmind
spring-mybatis
lightswitch-2013
preg-match
react-chartjs
directx-10
javascriptcore
google-cloud-endpoints-v2
pdb
jspresso
noraui
asset-pipeline
openoffice.org
accelerate-framework
google-api-nodejs-client
c11
tasker
nand2tetris
midl
outlook-api
apple-news
skeleton-css-boilerplate
logfiles
angular-resource
fault
pnotify
fancybox-2
media-player
pdfclown
mcafee
account-kit
passport-google-oauth
bonobo
dstu2-fhir
google-web-starter-kit
bstr
websitepanel
pagedlist
bluemix-app-scan
bluegiga
ios4
unity-networking
marching-cubes
cyclomatic-complexity
comobject
security-testing
composite
pretty-print
bridge.net
nsmutabledictionary
network-interface
cdt
java.util.concurrent
castle
resty-gwt
quartz-graphics
dataservice
excel-2003
lcs
path-separator
nsnetservice
google-email-migration
twrequest
objective-c-2.0
semantic-diff
code-cleanup
punbb
mod-auth
celltable
blitz++
thunderbird-lightning
libs
eqatec
boost-smart-ptr
geneva-server

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App