JTextField in JPanel looks too narrow

Hi guys,

Tried JTextField.size(width, height) but didnt make any difference, made sure the JPanel was big enough; how would I go about making the JTextField look wider? (right now it looks like 1px wide)

Also what am I looking for if I want to change focus from one JtextField to the next one when user pressed the Enter key? (there are 5 inputs).

Thanks a ton!!

[387 byte] By [Purefana] at [2007-10-3 4:50:42]
# 1

you can set the number of columns in the constructor

= new JTextField(10); or

= new JTextField("Hello World",10);

you can use the setColumns(..) method

textField.setColumns(10);

if you want to use a size, and the textfield is in a container (with layout manager),

you need to use

textfield.setPreferredSize(new Dimension(int,int));

for the focus with enter key, sample code in this post

http://forum.java.sun.com/thread.jspa?threadID=767493

look for the 'changes' section and the 'forwardKeys'

Michael_Dunna at 2007-7-14 22:55:20 > top of Java-index,Desktop,Core GUI APIs...