File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto Scroll List/Scroll Pane

 
Jeffrey Smith
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JList in a JScroll Pane on my form, and everytime I add somethign to the list, I want it to scroll down, So I can see ther last Item entered (at the bottom). iright now, it adds the item to the bottom, but the view remains at the top, I tried making it select the last item on the list, but that didnt change the scroll pane view, but I cant figure out how to make the scroll pane go down to the bottom after each new entry.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add this line after the code that adds to the listModel

list.ensureIndexIsVisible(listModel.size()-1);
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeffrey S.,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

We'd like something more than a single character for the displayed last name.

Thanks Pardner! Hope to see you 'round the Ranch!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum..
 
Jeffrey Smith
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK that works exactly like I wanted it to, thanks.

i was using this before:
lstlog.setSelectedIndex (listModel_lstlog.size ());
it isnt all that diferent, but one thing, your worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic