I need to iterate though all items in a list box.
:confused: How do I get ALL items in a listbox?
Printable View
I need to iterate though all items in a list box.
:confused: How do I get ALL items in a listbox?
if your list box is JList...
read JList (Java Platform SE 6)
if your list box is JCombobox
read JComboBox (Java Platform SE 6)
getItemAt(int index)
getItemCount()
may help you...
Thanks for the response mtyoung. It must contain the answer somewhere.
I'm a complete novice to Java but an experience vb.net programmer trying to ditch Microsoft.
Is it just me? - the link you sent seems daunting to a would be Java programmer.
I'm not asking anyone to write the code for me but the transition from Net to Java is not as trivial as I hoped.
I'll keep trying.
The link that @mtyoung gave should be regarded as the reference manual; it assumes you know the basics of Java and Swing.
You need to know the basics of Java: how to declare variables, how to write a loop, how to put classes together etc. This part is surely quite different to VB. If you were a C# programmer, it would probably seem much closer.
Then, I'd recommend you go through at least parts of a basic Swing tutorial, such as Sun's Swing tutorial. I think many of the concepts of the library classes will be similar to .Net (I'm not a .Net programmer, but the bits I've seen seem pretty much a direct rip-off from Java; not sure how the UI classes work, though).
Thanks Neil
I've got the basic of Java via Sams Teach yourself but it is not the best Sams that I have read. I'll take a look at the Swing tutorial.
At least search on the forum, or on the web. You can find lots of examples related to this. :)
Thanks Eranga
I've found a solution. I think I must switch off my VB.net brain and start thinking Java.