In Java, how to get attribute given the string with its name?
<p>I'm sorry for asking this sort of questions, but I really couldn't find the answer in Google. So say I have a class with <code>private String myColor</code> and I have a string "myColor". Now  I want to manipulate the <code>myColor</code> attribute. How can I do that?</p>

<p><strong>Edit:</strong>
Sorry for an unclear question, I guess the best way is to explain what I need it for. I've got a Swing form and want to use the preferences api to set the values of fields when loading gui. So I can read all the fields and then do <code>outputDirectoryTextField.setText(valueFromPrefsAPI);</code> for each of them, but that seems to be a bit of unneeded coding so I want to have an array(hash?) with the names of fields and loop through them, like this:</p>

<pre><code>String[] myTextInputs = {"thisInput", "thatInput"};
                for (String inputName : myTextInputs) {
                    String value = prefs.get(inputName, "");
                    /* some code I'm seeking to find out*/.setText(value);
                }
</code></pre>
