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

Answer:

You may have forgotten to register a listener with the button. Without a listener, the events are ignored.

A Swing Component: JTextField

A JTextField is a box that contains a line of text. The user can type text into the box and the program can get it and then use it as data. The program can write the results of a calculation to a JTextField. Here is a label and a text field (both inside of an applet):

To enter text into the field you must first click the mouse pointer inside of it. This gives the field the keyboard focus (usually just called focus). When a component has focus, characters from the keyboard are directed to that component. A component gets focus by various means. The user might click it, or the program might give it focus.

Enter some text. Edit it using back space and delete. Copy some text from the web page and paste it into the field. All this works. But the field is not connected to any application code so nothing is done with the text.

QUESTION 2:

(Review: ) Where is the class definition for JTextField?