how to resize a textfield?

I have added a JTextField to panel. But the TextField is too thick.any coding can make the TextField thinner?..thx all expert
[153 byte] By [s986289] at [2007-9-27 15:03:21]
# 1

If by too thick you mean too high, maybe you need to look at which layout manager you're using.

By default the layout manager for a JPanel is FlowLayout which shouldn't be a problem, but if you've set it to BorderLayout and then added the JTextField to the center it will resize vertically to fill the panel.

Alternatively you can control the size of a JTextField by using the methods setMinimumSize, setPreferredSize and setMaximumSize, but using the correct layout manager is usually easier.

Regards,

Tim

TimRyanNZ at 2007-7-5 23:03:32 > top of Java-index,Archived Forums,Swing...