Hi,
I am wondering if there is way to twist JList such that the highlight still remains on previously selected item after other item is selected.
For example, this list has 4 items: A, B, C, D
If I select A, A will be highlighted.
I then select C, C will be highlighted and A still remains highlighted as well.
I then re-select A again, A now becomes "de-highlighted".
Thanks in advance,
dvnjava
3 4411
Doesn't one of the selection modes, using the setSelectionMode( ... ) method help you?
kind regards,
Jos
Can you be more specific, JosAH?
I tried the below code borrowed from Hans Muller, Sun java website, and it makes item being toggle only but does not keep 2 items highlighted.
JList list = new JList(MyArray);
list.setSelectionModel(new ToggleSelectionModel());
class ToggleSelectionModel extends DefaultListSelectionModel
{
public void setSelectionInterval(int index0, int index1) {
if (isSelectedIndex(index0)) {
super.removeSelectionInterval(index0, index1);
}
else {
super.setSelectionInterval(index0, index1);
}
}
}
Try to set the selection mode: -
JList yourList ...;
-
-
yourList.setSelectionMode(
-
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Roman Thurnherr |
last post by:
Hi all
I'm using two JLists with the same MouseListener in a JFrame. How can I find
out on which JList the MouseEvent was released?
Is it generally possible or should I use a MouseListener for...
|
by: Tristán White |
last post by:
Hi there, this'll be an easy one I'm sure. I have a small question that will
take a second to answer, I am sure.
If you go to
http://snipurl.com/t821
All the buttons on the left are red, and...
|
by: no1zson |
last post by:
I am a beginner here, still in my first Java class, so I hope this question is not so simple as to offend anyone, but I am finishing up my cd inventory program.
Adding some GUI buttons to manipulate...
|
by: no1zson |
last post by:
I do not even know how to correctly ask this question.
I have an item field in the code I am about to post. Simple intger meant to be an item number for a cd. The user enters this number.
Over the...
|
by: Nepomuk |
last post by:
Hi!
I'm trying to use a JList. Here's the code:
String languages = {
"deutsch", // german
"english", // english
"castellano", // castilian
"français", //...
|
by: sukatoa |
last post by:
I came from List in awt....
Im currently having an experiment about JList....
say like 140,280 ( h,w )
i have 4 values that have been set on JList
using addElement from...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place.
...
|
by: dvjava |
last post by:
Hi,
I need to come up with a java program (JList) to monitor products/goods for my operation.
The program should let me enter products (items) or delete them, one at a time.
Once entered, a...
|
by: Gangreen |
last post by:
Hi all,
I've bumped into an odd problem creating a GUI in swing. As you will see in the screenshots, I have a tabbed layout. Each tab is a Jpanel. On this panel I have put a JList, containing a...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |