🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #480

Re: redefining JList behavior

#480
From: 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;
            }

        }

    } 
Technical Details
Message-ID: <42dace68$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder1.cambrium.nl!feed.tweaknews.nl!62.58.50.20.MISMATCH!nntpfeed.zonnet.nl!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42d88da2$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,dff767efc18d9a54
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Tony" <aoganesi_a^t_yahoo_._com>
Newsgroups: borland.public.jbuilder.java.swing
References: <42d88da2$1@newsgroups.borland.com>
Subject: Re: redefining JList behavior
Date: Sun, 17 Jul 2005 14:32:27 -0700
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 69.33.38.98
Message-ID: <42dace68$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1121635944 69.33.38.98 (17 Jul 2005 14:32:24 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder1.cambrium.nl!feed.tweaknews.nl!62.58.50.20.MISMATCH!nntpfeed.zonnet.nl!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail