Skip to content
Advertisement

JTextField size can’t be changed

JavaScript

} I tried to create a form and a JTextField on it. But the problem is, my location and size doesn’t work. The TextField is filling the whole form. How can I fix it?

Advertisement

Answer

The size is not “working” due to the default layout (FlowLayout) in your JFrame. This layout doesn’t let you change the size or location of any object. Try to use your own layout (modify x and y values in order to modify the size and location of your components):

JavaScript

You have to set the layout in the constructor of the JFrame:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement