> If update the field programmatically, changing the number of digits on
> display, the text field and it's enclosing panel are resized by a small
> amount.
>
> Any ideas on how I can stop this.
Specify the field's width by setting the number of columns,
or use a layout that doesn't measure the preferred size.
See JTextField#setColumns(int)
Hope this helps,
Karsten
Steve Jones - 02 Mar 2004 17:02 GMT
>> If update the field programmatically, changing the number of digits on
>> display, the text field and it's enclosing panel are resized by a small
[quoted text clipped - 6 lines]
>
> See JTextField#setColumns(int)
Thanks Karsten, your suggestion works fine.
I have just sub classed JFormattedTextField to see what getPreferredSize()
is returning. The width returned changes with the number of characters in
the field, even though the field's size, as set initially by the gridbag
manager, is far larger than the number of digits on display.
When I use setColumns() as you suggest, the width returned by
getPreferredSize() stays the same.
Cheers, Steve.