JTextField not sized properly

"jhuber" <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
I have come up with a solution for this.

I experimented with the AWT TextField and found that it did not have this problem.  Digging into the difference between TextField and JTextField provided a solution.

When text is added to the TextField, the caret is positioned at the beginning of the text.  When text is added to the JTextField, the caret is positioned to the end of the text, which pushes the text slightly to the left and pushes the first character beyond the border of the JTextField.

So after adding text to the JTextField with code, I use the setCaretPosition method to move the caret back to the beginning of the text, and the text is then properly positioned in the JTextField.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.