JList and Action listeners?

Discussion in 'Mac Programming' started by Rhalliwell1, May 15, 2009.

  1. Rhalliwell1 macrumors 6502a

    Joined:
    May 22, 2008
    #1
    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
     
  2. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #2
    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.
     
  3. Rhalliwell1 thread starter macrumors 6502a

    Joined:
    May 22, 2008
    #3
    thanks, i will look into ListSelectionListeners. :)
     

Share This Page