Scroll JList to bottom automatic .

J

Jonny

Hi,

How to automatic scroll a JList to bottom of the list, i.e when inserting
new elements. My list have i created like this:

JList jlist = new JList(objectArray);
JScrollPane scroll = new JList(jlist);

Any simple code to do this?

Best Regards
/Jonny
 
R

Roland

Hi,

How to automatic scroll a JList to bottom of the list, i.e when inserting
new elements. My list have i created like this:

JList jlist = new JList(objectArray);
JScrollPane scroll = new JList(jlist);

Any simple code to do this?

Best Regards
/Jonny

<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html#ensureIndexIsVisible(int)>

int lastIndex = jlist.getModel().getSize() - 1;
if (lastIndex >= 0) {
jlist.ensureIndexIsVisible(lastIndex);
}


--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top