🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Tony Sat, 16 Jul 2005 04:31
redefining JList behavior
#477
Author: Tony
Date: Sat, 16 Jul 2005 04:31
10 lines
1215 bytes
Hi,

I have a small problem and I would appreciate any ideas.
I would like to redefine the JList behavior to allow multiple
selection/unselection without having to hold down the "Ctrl"-key.
So, I would like to have the same behavior JList currently has
while holding down the "Ctrl"-key without having to hold it down.

Thanks a lot in advance!
Tony. 
Re: redefining JList behavior
#480
Author: Tony
Date: Sun, 17 Jul 2005 21:32
46 lines
2370 bytes
> I would like to redefine the JList behavior to allow multiple
> selection/unselection without having to hold down the "Ctrl"-key.
> So, I would like to have the same behavior JList currently has
> while holding down the "Ctrl"-key without having to hold it down.

Just in case if anyone is interested

    class ToggleSelectionModel extends DefaultListSelectionModel
    {
        boolean gestureStarted = false;

        public void setSelectionInterval(int index0, int index1)
        {
            if (super.getSelectionMode() != 
ListSelectionModel.SINGLE_SELECTION &&
                index0 == index1)
            {
                if (!gestureStarted)
                {
                    if (isSelectedIndex(index0))
                    {
                        super.removeSelectionInterval(index0, index1);
                    }
                    else
                    {
                        super.addSelectionInterval(index0, index1);
                    }
                    gestureStarted = true;
                }
            }
            else
            {
                super.setSelectionInterval(index0, index1);
            }
        }

        public void setValueIsAdjusting(boolean isAdjusting)
        {
            if (isAdjusting == false)
            {
                gestureStarted = false;
            }

        }

    } 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads