Example usage for javafx.collections ObservableMap addListener

List of usage examples for javafx.collections ObservableMap addListener

Introduction

In this page you can find the example usage for javafx.collections ObservableMap addListener.

Prototype

public void addListener(MapChangeListener<? super K, ? super V> listener);

Source Link

Document

Add a listener to this observable map.

Usage

From source file:Main.java

public static void main(String[] args) {
    Map<String, String> map = new HashMap<String, String>();
    ObservableMap<String, String> observableMap = FXCollections.observableMap(map);
    observableMap.addListener(new MapChangeListener() {
        @Override//  w  ww . ja  v  a2 s. c o  m
        public void onChanged(MapChangeListener.Change change) {
            System.out.println("change! ");
        }
    });
    observableMap.put("key 1", "value 1");
    map.put("key 2", "value 2");

}