📜  javafx 可观察集合 - 汇编代码示例

📅  最后修改于: 2022-03-11 14:48:10.654000             🧑  作者: Mango

代码示例1
import java.util.ArrayList;
import java.util.List;
//from w ww .j a v a 2  s .  c o m
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;

public class Main {

  public static void main(String[] args) {
    List list = new ArrayList();

    ObservableList observableList = FXCollections.observableList(list);
    observableList.addListener(new ListChangeListener() {
      @Override
      public void onChanged(ListChangeListener.Change change) {
        System.out.println("change!");
      }
    });
    observableList.add("item one");
    list.add("item two");
    System.out.println("Size: " + observableList.size());

  }
}