🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Clearing a JList

#11303
From: Michael Härtig
Date: Thu, 17 Jun 1999 00:00
33 lines
2127 bytes
Hi,

> Thanks for the help, but its not working.  I originally thought the
> "removeAll" method was for this purpose also, but this method extends from
> "Container" - I believe its responsible for removing a container's child
> components.  It does not remove objects stored within the JList.

Hmmmm I don't tryed it. Ok. Then my 2nd solution. Instead of using a
Vector use a DefaultListModel. It does the same like a Vector, but
better. You can add any Object to the model. If the Object has a
toString() method, this String will be shown in the List. You use
yourList.setModel(yourModel) to add the data. Later simply use
model.add(yourObject);.
To remove all use model.removeAllElements();
But this will crash if no elements are in the model. Test this with
model.isEmpty(); And read the documentation about DefaultListModel. It's
very useful. ;-) Much success with your list....

Michael
-- 
           //// 
          (o o) 
+-----ooO--(_)--Ooo---------------------------------------+ 
|                                                         | 
| Michael H�rtig                 Neumann & Partner        | 
|                                Informationssysteme GmbH | 
| Softwareentwicklung            An der Hohen Stra�e 1    | 
|                                08393 Meerane            | 
|                                                         | 
+------------Oooo-----------------------------------------+ 
        oooO (  ) 
        (  )  (_) 
         (_)
Technical Details
Message-ID: <3768FC2C.973334F9@nupis.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7kak6g$oos9@forums.borland.com> <3768E12A.2663E86@nupis.de> <7kapgd$oog11@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,a1790d240a431449
X-Google-Attributes: gid111d45,public
From: Michael Härtig <haertig@nupis.de>
Subject: Re: Clearing a JList
Date: 1999/06/17
Message-ID: <3768FC2C.973334F9@nupis.de>
X-Deja-AN: 490667543
Content-Transfer-Encoding: 8bit
References: <7kak6g$oos9@forums.borland.com> <3768E12A.2663E86@nupis.de> <7kapgd$oog11@forums.borland.com>
X-Accept-Language: de
Content-Type: text/plain; charset=iso-8859-1
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing