June 2002
Beginner to intermediate
640 pages
14h 24m
English
JTextField allows you to edit text in text fields. It's pretty basic and can be explained with a simple example. Import JTextField and JFrame from the javax.swing package.
>>> from javax.swing import JTextField
Create a frame and a text field, and add it to the frame. We'll use this text field to demonstrate how to set and read text. Create the frame.
>>> frame = JFrame()
Create the TextField instance.
>>> textField = JTextField(20)
Add the instance to the center of the frame.
>>> from java.awt import BorderLayout >>> frame.add(textField, BorderLayout.CENTER)
Default Layout ManagerThe default layout manager for the frame is BorderLayout, which essentially allows you to add components to a frame's north, south, east, and west ... |
Read now
Unlock full access