🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JList only showing one selection

#8005
From: Kevin Dwan
Date: Mon, 06 Nov 2000 00:00
42 lines
2580 bytes

"Joi Ellis [TeamB]" wrote:

> Kevin Dwan <kevin@blueberry.com> wrote:
>
> > Thanks, Joi. That did it.
>
> > Do you have a suggestion for clearing the JList, so that if the user changes the
> > selection, the old values get zapped?
>
> > I thought JList1.clearSelection would do it, but it does not.
>
> Isn't this from a JFileChooser?  The user will have already made and unmade
> whatever selections they wish.  It isn't until they press <ok> or whatever
> you named the accept button that the getSelectedFiles() method will return
> anything.
>
> JList1 is your own copy of the data list, it isn't the same list as the
> user is seeing embedded within the JFileChooser.  You can do anything you like
> to JList1 and it won't affect the JFileChooser.
>
> --
> Joi Ellis (TeamB)
> No direct email, please.
> For best results, post on news server newsgroups.borland.com!

Yes, the selections do come from a JFileChooser, and are written to the JList in
another panel. Since this other panel gives the user other decisions, it's to be
expected that sometimes users will page back to the first panel and change their
selections in the chooser. So I need to clear out the selections in the JList, if
there were any, at the head of my Approve button actionevent, and the
JList.clearSelection method isn't doing it. (I also need to do this action of clearing
the JList listing if the user presses my homegrown "Cancel Selections" buton.)

The problem may be that the default list model of a JList is immutable, and I have to
do something like set the JList to DefaultListModel with the setModel method, and then
zap the choices by operating on the instance of the ListModel. I tried doing this
using the ListModel's .clear() and .removeAllElements() methods, but they don't seem
to work as I expected either.

I didn't think it would be this difficult to just erase the list.
Technical Details
Message-ID: <3A075600.642F986E@blueberry.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3A021239.92AF1FD4@blueberry.com> <8tt9hf$kml3@bornews.borland.com> <3A0363E0.2BF1797E@blueberry.com> <8tvor2$dfj4@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,34638f00403429f8
X-Google-Attributes: gid111d45,public
From: Kevin Dwan <kevin@blueberry.com>
Subject: Re: JList only showing one selection
Date: 2000/11/06
Message-ID: <3A075600.642F986E@blueberry.com>
X-Deja-AN: 690511820
Content-Transfer-Encoding: 7bit
References: <3A021239.92AF1FD4@blueberry.com> <8tt9hf$kml3@bornews.borland.com> <3A0363E0.2BF1797E@blueberry.com> <8tvor2$dfj4@bornews.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing