🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #3493

Re: getSelectedItem() in listcontrol?

#3493
From: Joe Nuxoll
Date: Mon, 08 Dec 1997 00:00
25 lines
1435 bytes
Joie Tagum wrote:
> This is exactly what I need, too, except I've got an array of Strings, and
> have tried to do:  String[] getSelectedItem().getAll();
> but it gives me some funky result--[I@1ee01e when I do a System.out.pritnln.
> Do you happen to know what this is about, and how I can get the selected
> item from my list control?

I'll post it again:

int[] ListControl.getSelection().getAll()

This, if you look at the signature, gives you an array of ints, not an
array of Strings.  To get the Strings stored in the model, ask the model
for the items at the list of int addresses:

int[] selectedIndexes = listControl1.getSelection().getAll();
Object[] data = new Object[selectedIndexes.length];
for (int i = 0; i < selectedIndexes.length; i++) {
  data[i] = listControl1.get(selectedIndexes[i]);
  System.out.println("data at index " + selectedIndexes[i] + " = " +
data[i]);
}

 - Joe Nuxoll
Technical Details
Message-ID: <348CF712.AE5B2704@corp.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34830CC3.B6DF8C40@lehigh.edu> <348323E1.EF814660@corp.borland.com> <66i1c2$bf3@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,d47e4c667b5aa1c4
X-Google-Attributes: gid1089d0,public
From: Joe Nuxoll <jnuxoll@corp.borland.com>
Subject: Re: getSelectedItem() in listcontrol?
Date: 1997/12/08
Message-ID: <348CF712.AE5B2704@corp.borland.com>
X-Deja-AN: 296527402
References: <34830CC3.B6DF8C40@lehigh.edu> <348323E1.EF814660@corp.borland.com> <66i1c2$bf3@forums.borland.com>
Organization: Borland International, Inc.
Newsgroups: borland.public.jbuilder.java.api