0

Combobox displaying only 10 items

asked 2009-04-13 15:18:28 +0800

maruti gravatar image maruti
27

Combobox control is only displaying 10 data items at any time.

<combobox id="monthCbId" width="100px" />

monthList = new ArrayList<String>(13);
monthList.add("Select");
monthList.add("JAN");
monthList.add("FEB");
monthList.add("MAR");
monthList.add("APR");
monthList.add("MAY");
monthList.add("JUN");
monthList.add("JUL");
monthList.add("AUG");
monthList.add("SEP");
monthList.add("OCT");
monthList.add("NOV");
monthList.add("DEC");
ListModel monModel = new SimpleListModel(monthList);
monthCbId.setModel(monModel);

But the combobox is only displaying items until SEP. Is there any property so that it will display all the items in the listmodel.

Thanks,
Maruthi

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2009-04-14 06:42:32 +0800

kindalu gravatar image kindalu
255

updated 2009-04-14 06:44:05 +0800

You have to write your own model(not to use simpleListModel beacause it only supports for 10 rows)
the limit is the "nRows" in the getSubModel method(in simpleListModel)
Ps:When syncModel method be called it always pass nRows=-1 to getSubModel method.

	public ListModel getSubModel(Object value, int nRows) {
		final String idx = value == null ? "" : objectToString(value);
		if (nRows < 0) nRows = 10;
		final LinkedList data = new LinkedList();
		for (int i = 0; i < _data.length; i++) {
			if (idx.equals("") || _data<i >.toString().startsWith(idx)) {
				data.add(_data<i >);
				if (--nRows <= 0) break; //done
			}
		}
		return new SimpleListModel(data);
	}

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-04-13 15:18:28 +0800

Seen: 622 times

Last updated: Apr 14 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More