Frank
Frank

Reputation: 521

JavaFX 8 iterate hash map

Given this hashmap:

HashMap<TitledPane, Boolean> paneMap = new HashMap<>();   

I'm trying to set all values in the map to false (values are set selectively in the application after 'clearing' the map), but no matter what I have tried I cannot get an appropriate iterator which will allow me to set each boolean value. Can someone help please?

Upvotes: 1

Views: 1029

Answers (2)

Alberto
Alberto

Reputation: 1579

You can use lambda:

paneMap.replaceAll((k, v) -> Boolean.FALSE);

Upvotes: 0

Frank
Frank

Reputation: 521

Just spoke to someone by phone and there is a very simple answer which I just didn't see in the end, because I tried to make it too complicated (I hadn't realised that 'put' replaces any existing values.

 for (TitledPane p : paneMap.keySet()){
        paneMap.put(p, Boolean.FALSE);
    }

Upvotes: 1

Related Questions