title: How to create a KeyEvent
body: <p>When i create the <code>KeyListener</code>, it requires the following fields: </p>
  
  <pre><code>public void keyPressed(KeyEvent e) 
  {
  
  }
  public void keyReleased(KeyEvent e) 
  {
  
  }
  public void keyTyped(KeyEvent e) 
  {
  
  }
  </code></pre>
  
  <p>When i put <code>System.out.println(e)</code> into the <code>keyPressed</code> method, though, it returns this when i press the enter key: </p>
  
  <pre><code>java.awt.event.KeyEvent[KEY_PRESSED,keyCode=10,keyText=?,keyChar=?,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0] on javax.swing.JButton[,1,1,100x100,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Dynamic@13b33a0e,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=2,bottom=0,right=2],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=HI,defaultCapable=true]
  </code></pre>
  
  <p>This is obviously not a KeyEvent, so I cannot use it to call the <code>keyPressed(KeyEvent e)</code>. What I want to be able to do is simulate the pressing of a key, specifically the enter key, in a way that would activate the <code>keyListener</code> and would output that text into a JTextArea. </p>
  
  <p>Note: I looked at the accepted answer for  <a href="https://stackoverflow.com/questions/14572270/how-can-i-perfectly-simulate-keyevents">How can I perfectly simulate KeyEvents?</a>, and understood little of how it actually works, and i want code i understand. I also looked here <a href="https://stackoverflow.com/questions/7745959/how-to-simulate-keyboard-presses-in-java">How to simulate keyboard presses in java?</a>, but not i could not get the robot to work; nothing happened when a key was supposed to be pressed.</p>