Hashmap is empty when ActionListener is called
<p>I have some code that looks like the following:</p>

<pre><code>public class Application {

    public JTextField some_textfield;

    public HashMap&lt;String, Integer&gt; map;

    /*
     * public static main(String[] args)
     *  calls Application()
     */

    public Application() {
        initialize();
        initializeMap();
        System.out.println(map);
        //prints the map {"some_textfield" : 123}
    }

    private void initializeMap() {

        map = new HashMap&lt;String,Integer&gt;();
        map.put(some_textfield.getName(), 123);
        //...
    }

    private void initialize() {
        //...
        some_textfield = new JTextField();
        some_textfield.setName("some_textfield");
        some_textfield.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                System.out.println(map);
                //map is empty
            }
        });
        //...
    }
}
</code></pre>

<p>When I type something in the text field and trigger the actionListener, it prints an empty map <code>{}</code> in the console.</p>

<p>How can I fix this issue?</p>