Call a method from the ListSelectionListener

J

John Broadley

Hello,
I am building two separate classes. The first class extends the
JPanel, creates a JList and implements a ListSelectionListener.
The second class extends the JPanel, and creates a JTextField in it.

I create instances of both classes, and put them in a JFrame.

When the user selects an item from the JList in the first JPanel, my
listener code is called. In this case, I would like to send the
selected item text to the second JPanel to pass it to its JTextField.

I first started with having the JList and JTextField created in the
JFrame, and from the ListSelectionListener code, I was seeing the
JTextField, and communication was possible. After a while, I felt that
I need more functionalities, so I though of separating the JList, and
JTextField in two separate stand alone classes capable of handling
several types of requests, but then I was not able to have
communication between the two anymore.

Appreciate your help.
Thank you.
 
A

Andrew Thompson

Appreciate your help.

A couple of things.

1) Ask a question.
2) Do it on the best group <http://www.physci.org/codes/javafaq.jsp#cljh> *
3) Post code, rather than descriptions.
<http://www.physci.org/codes/sscce.jsp>

There is perhaps a more suutable group, but once you have
read and posted to c.l.j.help for a while, and read the
mini-FAQ posted every 4 days, you will know what it is.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top