Search code examples
javaswingresizejtextfield

How can I resize a JTextField?


How can I resize a JTextField?


Solution

  • If you look at the Javadoc, you'll see that JTextField derives from Component, and that has a setSize() method. If you don't have a layout manager then that's of use.

    If you do have a layout manager, then setPreferredSize()/setMinimumSize()/setMaximumSize() is the way to go. See this SO answer for more details.