๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Beginner : JList ?

#11050
From: Tor Iver Wilhelmsen
Date: Mon, 12 Jul 1999 00:00
24 lines
1302 bytes
"Jean-Fran๏ฟฝois Leroux" <jfleroux@club-internet.fr> writes:

> Hi, I have a problem with JList : how can I ADD items to an existing
> JList, without creating a new 'JList(mydata)' ?

If you have dynamic list content, you are supposed to use a
_model_. Look at DefaultListModel for a usable and simple
implementation.


> And then how can I sort these items ?

The simplest is to get all the elements into an array, sort the array
using Arrays.sort(), then create a new model based on the array and
set it as the JList's model.

> It's quite easy in Delphi, but hard in java, and Jbuilder doesn't
> help in this case.

It's not hard in in Java, only different. :-)

If you want to do it closer to Delphi, you may want to look at
Microsoft's WFC, but then you'll restrict yourself to newer versions
of Microsoft's JVM for runtime.
Technical Details
Message-ID: <u3dyu5llb.fsf@sds.no>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7mb0vm$p2p18@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,95e4f1457d5ba466
X-Google-Attributes: gid111d45,public
From: Tor Iver Wilhelmsen <tor.wilhelmsen@sds.no>
Subject: Re: Beginner : JList ?
Date: 1999/07/12
Message-ID: <u3dyu5llb.fsf@sds.no>
X-Deja-AN: 500031011
Sender: towi@SDSA1761
References: <7mb0vm$p2p18@forums.borland.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing