title: Save user inputted values from jtextfield to a string that is used in hashmap
body: <p>I have two <code>JTextField</code> s and a <code>JButton</code>, one textfield saves to "key" and the other saves to "value"</p>
  
  <p>How do I get it to save this data from the <code>JTextField</code> and add to the key and value.</p>
  
  <p>Also, How do I take the "value" of the <code>HashMap</code> and add that to a <code>JList</code>?</p>
  
  <p>Thank you, this has been troubling me, everything I find about <code>HashMap</code> s is strings you enter in the code, not allowing the user to do so.</p>
  
  <p><strong>EDIT</strong>
  This is what I have in the jbutton action performed section: ( I'm using designer in netbeans )</p>
  
  <pre><code>lm.addElement(capitalText.getText());
  lm.addElement(countryText.getText());
  </code></pre>
  
  <p>(capitalText and countryText are what my two jtextfields are name ) </p>
  
  <p>This is the code I have preceding this:</p>
  
  <pre><code>private String country;
  private String capital;
  private DefaultListModel&lt;String&gt; lm = new DefaultListModel&lt;&gt;();
  Map&lt;String, String&gt; hashMap = new HashMap&lt;&gt;();
  String key = country;
  String value = capital;
  </code></pre>
  
  <p>Honestly I've just took different things I found online and tried to combine it to make something work and have been unsuccessful </p>