JLists

F

freesoft_2000

Hi everyone,

I have three JLists in three individual JScrollPanes.
All the objects in the JLists are equal in size

What i need to is when i select an object in a certain JList, the index
second and third JList is selected and also the JScrollPane is supposed to
automatically scroll to that position so that the selected indices are
visible by the user

This is how far i have gotten so far.
The selection part is already done but i can't get the individual
JScrollPanes of the second and thirs JLists to scroll to the part that is
being selected in the first JList

I am listing what is in the ListSelectionListener

public void valueChanged(ListSelectionEvent evt)
{
JComponent d = (JComponent)evt.getSource();

if(d == List1)
{
//The below three command lines sets the selected indices of List2 and
List3
//according to the selected indices of List1

int[] k = List1.getSelectedIndices();
List2.setSelectedIndices(k);
List3.setSelectedIndices(k);
}

Please assume the first JList is called List1, the second List2 and the
third
List3

Some sample coding would be helpful

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
V

Vova Reznik

freesoft_2000 said:
Hi everyone,

I have three JLists in three individual JScrollPanes.
All the objects in the JLists are equal in size

What i need to is when i select an object in a certain JList, the index
second and third JList is selected and also the JScrollPane is supposed to
automatically scroll to that position so that the selected indices are
visible by the user

This is how far i have gotten so far.
The selection part is already done but i can't get the individual
JScrollPanes of the second and thirs JLists to scroll to the part that is
being selected in the first JList

I am listing what is in the ListSelectionListener

public void valueChanged(ListSelectionEvent evt)
{
JComponent d = (JComponent)evt.getSource();

if(d == List1)
{
//The below three command lines sets the selected indices of List2 and
List3
//according to the selected indices of List1

int[] k = List1.getSelectedIndices();
List2.setSelectedIndices(k);
List3.setSelectedIndices(k);
}

Please assume the first JList is called List1, the second List2 and the
third
List3

Some sample coding would be helpful

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Why don't you read doc. first?
And, your lists together look like JTable.

JList::ensureIndexIsVisible(int)
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top