How can I get an Object's name in java?
<p>like this, A a = new A(), how can I get a's name?(Get a String "a" from a) ?</p>

<hr>

<p>There is a JPanel contains some JTextFields, a map contains all the JTextFields' names(the variables' names). I want to set the map's values to the JTextFields' texts.</p>

<pre><code>public void mapToJPanel(Map map, JPanel panel) {
    Component[] compArr = panel.getComponents();
    for (Component comp : compArr) {
        if (comp.getClass().getSimpleName().equals("JTextField")) {
            JTextField textField = (JTextField) comp;
            textField.setText(map.get(textField.getName()).toString());//getName() method
        }
    }
}
</code></pre>

<p>Accross getName() method, I get null -_- I know the getName() method is not used to get the variable name.
I'm using netbeans doing Java swing visual development , so I can not  rewrite the components(like JTextField).</p>
