Helooo,

Attached is a pic of my main screen of my program. Basicly it's a phone book app similiar to one you'd have on your phone. The thing that I can't wrap my mind around, is that you see the nice big textArea there?
After you've added a contact now. What can I use that the user can just click on the name of the contact in the textArea and the appropriate window will display for the contact?

As far as I know, you cant add an actionListener on a piece of text in a textArea. So what do I do? I've also considered packing the textArea full of JButtons displaying the persons name. But that just sounds a bit dodgy...

Oh yes and the contact I'm talking about is just a instance of my Contact class. Asin:

public Contact(String name, String surname, String mobile); //etc etc

Any help please!!

Use a JList and not a JTextArea

Add a scrollview and in that add JButtons(programmatically).

Okay what's going to be the easier one here now? By the sound of it the JList. Can you add an actionListener to a JList item?

Ah you can, thanks humans!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.