Configuring the JTextField
The JTextField
is added first (lines 41–45). The weightx
and weighty
values are set to 1. The fill
variable is set to BOTH
. Line 44 specifies that the JTextField
is the last component on the line. The JTextField
is added to the content pane with a call to our utility method addComponent
(declared at lines 79–83). Method addComponent
takes a Component
argument and uses GridBagLayout
method setConstraints
to set the constraints for the Component
. Method add
attaches the component to the content pane.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.