views:

614

answers:

1

Hi,

I have a JTextField with a fixed width, let´s say 100 pixel. Now, I put a text inside this JTextField whose length is greater than "100 pixel", means you have to scroll in the JTextField (possible width mouse). The JTextField isn´t editable.

How can I make sure that the part of the text I see is the beginning, not the end of the text. Hope you got what I mean... In my current example I just see the end of the string in the JTextField.

Like: "one two three four" is the string in my JTextField and I just see this: "wo three four". To see more, I have to scroll left, how can I set the curser the the left so that I see sth. like: "one two thre"?

+2  A: 

Have you tried JTextField.getCaret().setDot(…)? Setting the caret position to 0 should place it at the beginning of your text and cause the text to scroll to the beginning to make it visible.

Bombe
thx :) that worked
Tobiask
Or textField.setCaretPosition(0);
camickr