This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Actually you do not declare the length of the textfield by passing an int to the constructor. You define the number of characters it can contain (by default). The number of columns will set the preferred size of the component accordingly.
If you want the textfields to be square you will have to set the bounds of those textfield.
If you set the PrefferedSize of a component the layout manager will use this if enough space is available on the parent component. There is also something called minimumSize. If the layout manager notices that the parent component is to small for the child to fit. It will shrink the component taking in account the minimumsize.
You actually have to call the setPreferredSize(int width,int height) method for every component (textfield) that you wish to add. Be aware that the layout manager will also play with the sizes however. If you just want to add a number of textfields on a panel you can use the FlowLayout for instance.