The Artima Developer Community
Sponsored Link

Java Answers Forum
how to position scrollbar in scrollpane

5 replies on 1 page. Most recent reply: Sep 29, 2005 3:21 AM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Yogesh

Posts: 19
Nickname: kyogesh
Registered: Sep, 2004

how to position scrollbar in scrollpane Posted: Sep 27, 2005 11:21 AM
Reply to this message Reply
Advertisement
I have a scrollpane containing a textarea.
i want to set the vertical scrollbar of scrollpane to
the initial values (at the top of scrollpane) so that
i can view the first line of the content in text area

how to achieve this


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how to position scrollbar in scrollpane Posted: Sep 27, 2005 11:07 PM
Reply to this message Reply
Like what do you mean. Every time I place a JTextArea
in a ScrollPane, I don't have to worry about the Scrollbar
settings - unless you have a very specific way you want
it to function. The ScrollPolicies are automatically set.

Well at least in terms of the Java 5 on the desk top I'm
using right now and Java 1.4.2 that is on my laptop.

Doesn't simply doing:
JTextArea myText = new JTextArea(col, rows);
JScrollPane scrollPane = new JScrollPane(myText);

do the trick for you?

What ScrollPolicies are you trying to satisfy? Or maybe
you are using an older Swing Library that did not support
this?

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: how to position scrollbar in scrollpane Posted: Sep 27, 2005 11:51 PM
Reply to this message Reply
I think he's looking for
scrollPane.getViewport().setViewPosition(new java.awt.Point(0, 0));


Could be that there could be a problem if myText allready contains a lot of text and if the scrollpane is set to autoscroll.

Yogesh

Posts: 19
Nickname: kyogesh
Registered: Sep, 2004

Re: how to position scrollbar in scrollpane Posted: Sep 29, 2005 2:34 AM
Reply to this message Reply
yes exactly
you guessed it right
i have lots of text in text area.
ur solution worked.

also i got one more solution to my problem

txtArea.setCaretPosition(0);


thanks :)

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how to position scrollbar in scrollpane Posted: Sep 29, 2005 3:16 AM
Reply to this message Reply
Tx, I'm now using that in a team project.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how to position scrollbar in scrollpane Posted: Sep 29, 2005 3:21 AM
Reply to this message Reply
Great! Thanks again, works like a charm...

Flat View: This topic has 5 replies on 1 page
Topic: chained exception--websphere doubt Previous Topic   Next Topic Topic: Directory Conents from URL

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use