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 4413 JosAH 11,448
Recognized Expert MVP
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);
}
}
}
JosAH 11,448
Recognized Expert MVP
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: 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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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: 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: 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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |