how to get rid of trailing blank space in JTextField
- From: Ray Ma <Wenj.Ma@xxxxxxxxx>
- Date: Fri, 14 Sep 2007 19:48:20 -0000
Hi, there,
I thought this would be simple but I didn't find any answer by
searching.
My problem is not how to restrict user input to JTextField to a fixed
length.
The problem is, I need the JTextField to be almost exactly the same
length as the column of characters I entered.
I have set the allowed text input length to be 8 for example by using:
JTextField textField.setColumn(8);
textFieldContainerPanel.validate();
and I can see that the textField does shrink a little bit compare to
when I use setColumn(20); It does only allow user input to 8
characters.
But after I finish entered 8 characters from left to right, there's
still some blank space between the 8th character to the right edge of
the textField. (around 5 characters) It seems that the textField
layout manager always tries to leave more space than it needs for just
holding the "column" number of characters.
There is previous post:
http://groups.google.com/group/comp.lang.java.gui/browse_thread/thread/977cea7ef7745570/ac4fab7e991e768f?lnk=gst&q=JTextField+length&rnum=8#ac4fab7e991e768f
that suggest to get a hold of the Font object, can someone give more
detail on this method if appropriate?
same question asked at:
http://forum.java.sun.com/thread.jspa?threadID=701287&messageID=4068100
with no answer.
.
- Follow-Ups:
- Re: how to get rid of trailing blank space in JTextField
- From: Roedy Green
- Re: how to get rid of trailing blank space in JTextField
- Prev by Date: Re: [follow] issue with jws
- Next by Date: Re: [follow] issue with jws
- Previous by thread: [follow] issue with jws
- Next by thread: Re: how to get rid of trailing blank space in JTextField
- Index(es):
Relevant Pages
|