Example usage for javafx.collections FXCollections observableMap

List of usage examples for javafx.collections FXCollections observableMap

Introduction

In this page you can find the example usage for javafx.collections FXCollections observableMap.

Prototype

public static <K, V> ObservableMap<K, V> observableMap(Map<K, V> map) 

Source Link

Document

Constructs an ObservableMap that is backed by the specified 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// ww w . ja va 2s.co  m
        public void onChanged(MapChangeListener.Change change) {
            System.out.println("change! ");
        }
    });
    observableMap.put("key 1", "value 1");
    map.put("key 2", "value 2");

}