hello!
anybody knows how can i set a JList item (saving previosly in a JSON file) with the PATH and not with INDEX?
this is becouse my list are dinamic, and maybe when i save a selection (index 2, e.x), next when i want load index 2 is not my selection(becouse i add a new item o delete)…
int indexfrag = shader.getInt("shaderpathF");
JList f;
f.setSelectedIndex(indexfrag);
i need something like f.setSelectedString or path… this is possible?
Without seeing more of your code / knowing more about what you are trying to do, I’m not sure that I understand your question. I can’t tell what type of object shader is (PShader?) or what you mean by PATH (filepath string?).
In general, if you have a set-by-index object that you want to set-by-string, one way is to create a Map (like a HashMap) and store the string as the key and the index as the value. Then you can f.setSelectedIndex(map.get(“mykeystring”));