how to get rid of trailing blank space in JTextField



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.

.



Relevant Pages

  • Max num of enterable characters in a TextField/JTextField
    ... How does one specify the maximum number of characters that may be entered in ... a TextField or JTextField? ... Gregg ...
    (comp.lang.java.gui)
  • Ignore F1-F12 keys when user enters text input on console
    ... The user input it taken using STDIN.getc. ... the entered characters are not displayed and each character is ... obscured by displaying an asterix. ... def TestFunc ...
    (comp.lang.ruby)
  • Re: [Full-Disclosure] How T-Mobils network was compromised
    ... User input is passed to a function which sanitizes the input by ... converting "dangerous" characters to HTML representations. ... Function is flawless from a programming perspective and performs as ... should have occurred is a check for "../" in a loop. ...
    (Full-Disclosure)
  • avoid which characters in text fields with vb- and jscript?
    ... native win2k3 srv/xp clients environment on our IIS 6.0 intranet ... Have made various tables storing user input, ... sure to clean user inputs for unwanted characters before storing in ... Using the vbscript Replace funktion Im able to remove quotes ...
    (microsoft.public.scripting.vbscript)
  • Re: What chars are considered safe?
    ... > I was just writing a sanitisation route for a bit of user input. ... > an English text description of a product, and will go into a DB, then back ... > characters that I considered safe and stripping out everything else. ...
    (comp.lang.php)