Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem with JList, DefaultListModel and JScrollPane

Thread Tools

Problem with JList, DefaultListModel and JScrollPane

Tobi Krausl
Posts: n/a

I've the following problem with JList, DefaultListModel and
How can I get a JList (JScrollPane) which automatically scrolls down
and shows the last entry added to the list?
In my program there are several classes manipulating a
DefaultListModel connected to a certain JList. To handle that, the
constructor of each class gets a reference to that DefaultListModel.
Ok, up to now it all works pretty fine. But if the JList gets bigger
and Scrollbars are added, the user has to scroll down "manually" to
see the bottom of the list. How can I handle the JList/JScrollPane to
select and show always(!) the bottom of the list everytime myListModel

I tried the following:

new ListSelectionListener() {

public void valueChanged(ListSelectionEvent e) {
int i=0;




This works, but only when the users clicks on the list.
Could you please help me?

Tnx so much,
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Jscrollpane and jtable yashiro Java 2 05-17-2008 11:52 AM
JTable and JScrollPane Java 3 07-19-2007 12:35 PM
Swing DefaultListModel question. Java 2 09-17-2005 07:35 AM
JScrollPane Problem Dipak Java 3 07-27-2004 03:32 PM
JScrollPane problem Konstantin Semlizki Java 1 07-08-2004 07:18 PM