I have displayed 4 JList's in a row , where each of the Lists has barcode getting
displayed from the input read through machine. Input read sequence is
For 1st piece read - List1,List2, List3 and List4 items are displayed
For 2st piece read - List1,List2, List3 and List4 items are displayed
For 3rd piece read - List1,List2, List3 and List4 items are displayed
Repeats for N pieces.
My question is how to automatically select or highlight the recent last item
getting displayed in 4 lists without user selecting the item. This is required for
the user to view and find which was the last piece read by the machine.
Any help is accepted and thanks for consideration.
Thanks for the answers.
I have solved the problem myself by doing :
This will automatically select the last recent item displayed in 4 Lists on the frame. But still i have one issue with on of the List's on the frame.
Please look at the attached file. Current working behavior is shown in Frame1 . The expected behavior is shown in Frame2.
In Frame1 :
The recent items are selected in List1 , List2, List3 and List4 as soon as the machine reads. But the last item in List4 is not selected as same number 10 is repeating several times. It selects the first occurrence and
i assume because DefaultListModel closely behaves as vector and the lastElement() returned for same numbers in the vector will be first occurrence. I have to make it work as in Frame2. Please suggest any ideas.
After posting the question i was working and i did the same as you said . It worked.
posted 10 years ago
I have an extended question to this post.
How could i draw a line border around the selected item instead of highlighting? I have implemented ListCellRenderer and have set the border with LineBorder but that does for each item and not only the last item in the list.
I need to have a border because some of the text in the Lists can have different colors and it gets hidden if selected by index as by default it sets the List background and foreground. It should look like the one i have in the attached file.