-2

I inserted a text field and now I just want it to say "working" within the text field. I do not have any errors, but when the display comes up the text field is empty. The first line of the code below was generated by netbeans. I wrote the second line.

 private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
      jTextField1.setText("working");
 }
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • 2
    This code is only called if you press the enter key when the caret is within the JTextField. Please go through the Swing tutorials, and you can find the link within the [Swing Info link](http://stackoverflow.com/tags/swing/info). – Hovercraft Full Of Eels Nov 29 '16 at 21:47
  • 2
    `setText("working");` This could imply a long running task is underway. Two tips: 1) Don't block the EDT (Event Dispatch Thread). The GUI will 'freeze' when that happens. See [Concurrency in Swing](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/) for details and the fix. 2) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Nov 29 '16 at 23:18

1 Answers1

0

Looks like you are trying to do that in the wrong method --> jTextField1ActionPerformed

try moving this to a OnClickEvent or in the initComponents of the App

jTextField1.setText("working");
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97