A good answer might be:

Because you say exactly where the text will go:

drawString( String, xLocation, yLocation )

You decide this, not the layout manager. Because this drawing is not controlled by the layout manager, the GUI will get messed up.

Listener for JTextField

A JTextField is a Swing component, so there must be a listener object for it to be useful to the program. When text is entered the user can hit the enter key. This generates an ActionEvent just as does clicking on a button.

Now the program needs to get the text and do something with it. To get the text use the String getText() method.

To put text into a TextField use the setText(String stuff) method.


What type of listener is needed for an ActionEvent?