title: How can I make my textarea accept inputs in a script engine like a compiler?
body: <pre><code>ScriptEngineManager manager = new ScriptEngineManager();
  ScriptEngine engine = manager.getEngineByName("JavaScript");
  
      try {
          engine.eval("load(\"nashorn:mozilla_compat.js\");");
          engine.eval( ""
                  + "var Gui = new JavaImporter(java.awt, javax.swing,java.awt.event,javax.swing.event);"
                  + "with (Gui) {\n" 
                  + "var jframe = new JFrame(\"Console\");\n"
                  + "var textarea = new JTextArea(10,30);\n"
                  + "var jScrollPane = new JScrollPane(textarea);\n"
                  + "jframe.add(jScrollPane);"
                  + "jframe.setSize(500,300);"
  
                  +"var Name;"
                  + "textarea.append(\"HELLO \");"
                  + "jframe.setVisible(true);"
  
                  + "if(keyCode==KeyEvent.VK_ENTER){"
                  + "Name= ;"
                  + "textarea.append(\"\"+ Name );"
  
                  + "}"
                  + "setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);" 
                  + "jframe.setVisible(true);"
                  + "}");
  
  
      } catch (ScriptException ex) {
          Logger.getLogger(Compiler.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>