Menu

#43 ListBox getSelectedValue: Model Size Checking

open
nobody
None
5
2005-02-04
2005-02-04
No

Hello!
I need ListBox.getSelectedValue() do a model size
checking prior doing the
model.get(getMinSelectedIndex()) to avoid
---
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
13:24:21,795 INFO [STDOUT] at
java.util.ArrayList.RangeCheck(ArrayList.java:507)
13:24:21,795 INFO [STDOUT] at
java.util.ArrayList.get(ArrayList.java:324)
13:24:21,795 INFO [STDOUT] at
nextapp.echo.DefaultListModel.get(DefaultListModel.java:96)
13:24:21,795 INFO [STDOUT] at
nextapp.echo.ListBox.getSelectedValue(ListBox.java:247)
---

It would be nice something like:
vvv
value=selectedIndex<model.size()?
model.get(selectedIndex) : null;
^^^
instead of:
vvv
value = model.get(getMinSelectedIndex());
^^^
on ListBox.getSelectedValue().

Thanks!

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.