go to previous page   go to home page   go to next page


FlowLayout does the best it can, and puts the components on top of each other. If the frame is not wide enough, the text field will be truncated.

Listener for JTextField

A JTextField is a Swing component, so there must be a listener object for it to be useful to the program. After entering text, the user hits the enter key. This generates an ActionEvent just like clicking on a button.

The listener needs to get the text and to do something with it. Use the String getText() method to get the text in the field.

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


What type of listener is needed for an ActionEvent?