It does make the difference JTextField()->empty textfield JTextField(10)->textfiels with 10 columns(the column width 'll change slightly according to size of font) JTextField(100)->textfield with 100 columns(mean can hold 100 chars not 100 pixels) basha
But why. It doesn't actually place any constraints on the TextField as far as user input. Why doesn it matter if I tell it to hold 100 characters when my textfield is wider than that anyway, or why tell it to hold 10 characters when my textfield is shorter than that. I don't know if I am explaining myself correctly, but in my code,
It doesn't matter if I have the 10 in the constructor or not.
Hi Gregg, From the API docs, columns - the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation It just alters the preferred size. If the layout manager honors preferred size, it will use it. By doing setBounds(), you are overriding the layout mechanism also and hence you will not see any effect. Some more info here: http://www.developer.com/java/ent/article.php/610011 - Raj