PDA

View Full Version : JList and Action listeners?




Rhalliwell1
May 15, 2009, 09:06 PM
Hi,

I am trying to write a simple app whereby on the left you have a JList, when you click on an item of the list the details are shown in a JTextArea on the right. I have implemented the JList and the JTextArea but having problems getting the two to speak to each other. Anybody got any suggestions. I am trying to avoid having to click a JButton to update the JTextArea.

(This app will mimic apple's Address Book.app (sort of))

many thanks



Guiyon
May 16, 2009, 06:12 AM
The simplest way would probably be to just add a ListSelectionListener to the JList and perform the update to the JTextArea (or whatever other elements you want) in the valueChanged method.

Rhalliwell1
May 16, 2009, 06:30 AM
thanks, i will look into ListSelectionListeners. :)