Scrollbar pproblem

Hi,

I am using JTextField wil scrollbar.

I have provided search functionality where user will search for any string in that textfield.

If search string is present in the lower part of textfield display area does not get changed.

User has to change scrollbar position in order to view highlighted line.

Does anybody have solution to this problem?

[382 byte] By [SSonya] at [2007-10-3 2:59:34]
# 1
> Does anybody have solution to this problem?Doesn't setting the cursor to the found position scroll the view?
CeciNEstPasUnProgrammeura at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 2
Yes.Display area should get changed. I need to manually scroll in order to view highlighted area.
SSonya at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 3
> Yes.> Display area should get changed. I need to manually> scroll in order to view highlighted area.Do you move the cursor?
CeciNEstPasUnProgrammeura at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 4
no
SSonya at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 5
I am using textfield only to display text. It's not editable.
SSonya at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 6
> noWhy not? I told you that msetting the cursor should scroll the view. (I think. I'm not a Swing expert, they're all in the Swing forum.)
CeciNEstPasUnProgrammeura at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 7
Its working fine now! Thank you very much!
SSonya at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 8
But it removes selection. First I am selecting that line and then setting caret position. It works fine but removes highlighted or deselects search string.
SSonya at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 9
Then set the caret position first, before selecting.
CeciNEstPasUnProgrammeura at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 10
Then search string gets selected but original problems come.
SSonya at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...
# 11
Swing related questions should be posted in the Swing forum.Rectangle r = textField.modelToView( textField.getSelectionStart() );textField.setScrollOffset( r.x );
camickra at 2007-7-14 20:49:10 > top of Java-index,Java Essentials,Java Programming...