Skip to content

KeyValueTable

Jonato edited this page Feb 27, 2016 · 2 revisions

KeyValueTableView is a customized generic TableView for Key/Value Pairs. The control can skip keys by an second list.

    private KeyValueTableView<String, ArrayList<String>> keyValueTableView;

    @Override
    public void start(Stage primaryStage) throws Exception {
        keyValueTableView = new KeyValueTableView<>();

        ArrayList<String> vornamen = new ArrayList<>();
        vornamen.add("Hans");
        vornamen.add("Tobias");
        vornamen.add("Peter");

        ArrayList<String> nachnamen = new ArrayList<>();
        nachnamen.add("Lahm");
        nachnamen.add("Ribery");
        nachnamen.add("Robben");

        //CREATE KEY / VALUE PAIRS 
        ArrayList<Pair<String, ArrayList<String>>> data = new ArrayList<>();
        data.add(new Pair<>("vornamen", vornamen));
        data.add(new Pair<>("nachnamen", nachnamen));
        data.add(new Pair<>("Ausblenden", new ArrayList<>()));
        data.add(new Pair<>("Ausblenden 2", new ArrayList<>()));

        keyValueTableView.setAllItems(FXCollections.observableArrayList(data));

        //DONT SHOW THE skippedKeys ArrayList in output
        ArrayList<String> skippedKeys = new ArrayList<>();
        skippedKeys.add("Ausblenden");
        skippedKeys.add("Ausblenden 2");

        keyValueTableView.setSkippedKeys(FXCollections.observableArrayList(skippedKeys));

        Scene scene = new Scene(keyValueTableView, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
Clone this wiki locally