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
Roland - 05 Oct 2005 21:26 GMT
> Hi,
>
[quoted text clipped - 8 lines]
> Best Regards
> /Jonny
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html#ensureIndexIsVisi
ble(int)>
int lastIndex = jlist.getModel().getSize() - 1;
if (lastIndex >= 0) {
jlist.ensureIndexIsVisible(lastIndex);
}

Signature
Regards,
Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \