🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Adding a string to a JList

#95
From: Paul Furbacher [TeamB]
Date: Thu, 19 Jan 2006 04:20
38 lines
2196 bytes
John Meyer wrote:

> How do I add a string to a JList?

As with all Swing components, get the underlying
model.  In the case of a JList, the "concrete"
underlying model is DefaultListModel, so when you
ask

   myList.getModel();

you have to typecast the returned value to DefaultListModel
in order to use the methods which add an object to the
list.  Note that the list may not contain just String
object, but any object which has a "toString()" method.


It may be time to read the tutorials on Swing at the
java.sun.com Web site, or better yet, get a good book
on Swing.  It's complex, so there's no better way
to invest in your career than to buy a good book now
and then.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Technical Details
Message-ID: <43cf12e0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!meganewsservers.com!feeder2.on.meganewsservers.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43ceddfe@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,cce83396da78078c
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 18 Jan 2006 23:20:17 -0500
From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Adding a string to a JList
References: <43ceddfe@newsgroups.borland.com>
In-Reply-To: <43ceddfe@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.142.194.228
Message-ID: <43cf12e0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1137644256 69.142.194.228 (18 Jan 2006 20:17:36 -0700)
Lines: 38
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!meganewsservers.com!feeder2.on.meganewsservers.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail