• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I get a string from an item in a dynamic jlist?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Forte for Java Internet Edition to write an application that uses an nbCacedRowset from a database query at runtime to dynamically populate a jlist. Next to the jlist is a panel of text fields that needs to be dynamically populated with information from the same database depending on what item in the jlist is focused on. More specifically, items in the jlist are pieces of equipment whose corresponding status/information is to be displayed next to it in a status panel. Understand? Is there some way that I can return the value or string from the focused item in the jlist to be used in a query to populate the text fields in the status panel? Any help you could give me would be appreciated.
Thanks,
Craig

[This message has been edited by csnowbar (edited March 07, 2001).]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"csnowbar",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I bet you'd have a better chance of getting an answer if you pared down your messages to a reasonable length. Have you tried using JList.addListSelectionListener()?
J.Lacar
 
csnowbar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by JUNILU LACAR:
I bet you'd have a better chance of getting an answer if you pared down your messages to a reasonable length. Have you tried using JList.addListSelectionListener()?
J.Lacar


I have a ListSelectionListener in my code, but according to http://java.sun.com/j2se/1.3/docs/api/javax/swing/event/class-use/ListSelectionListener.html, AccessibleJList is the only class that implements ListSelectionListener for a JList. How can I use AccessibleJList to return the string of a selected item in a JList? Or am I way off track here?
TSList = private void addListSelectionListener(ListSelectionListener TSListFocus)
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java API documentation on JList has an example of getting the index of the item clicked on using an anonymous inner class that extends MouseAdapter(). The JList method used is locationToIndex(). Assuming that setSelectionMode(ListSelectionModel.SINGLE_SELECTION) so the user can select only one item at a time though, you can just cast the return value of getSelectedValue() to a String and go from there.
See How to Use Lists in the Java Tutorial Also see the article Advanced JList Programming in The Swing Connection.
J.Lacar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic