简体   繁体   中英

How to get one entry in a Jlist to work with entries in another JList?

Bear with me. I have a denist program with 3 JList's. A patient JList that adds patients, a history jlist that adds the patients history and an invoice history that should link with the history jlist and the patient jlist. I have them all writing to each Jlist respectably but my aim is: when i click on a patient , their history will pop up in the history JList and the invoice will appear in the Invoice Jlist.

How would i go about this? I have id's in each jlist. I think this would be the right way to go about it.

More than happy to send the program via email if needed.

Need help!!

Thanks.

Well, just add ListSelectionListener(s) to your JLists and when the selection changes find the appropriate object for your other JLists to display.
You can call list.getModel().getElementAt(i) to get the elements contained in the list. Find the appropriate one by whatever mechanism you have to identify linked items. Once you have the item just call list.setSelectedValue(yourObject, shouldScroll) and that's it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM