🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Please Help ME...(Problem about JList & JCombobox)

#10191
From: Gerry Stechow
Date: Fri, 05 Nov 1999 00:00
44 lines
1693 bytes
hi eric,

swing implements an model-view-controller concept.
this means, that the data aren't direct stored in the jList (view),
but it's stored in an underlying ListModel (model). if you don't specified 
one, swing uses the DefaultListModel.

how to add an entry:

jList1.getModel().add(Object element);
or
jList1.getModel().add(int index, Object element);

the add-methode fires an event and the view will be updated.

cu gerry

ERic wrote:
> 
> My problem is:
> 
> When in AWT, I can use "list.add()" or "list.addItem()" to add data
> items to my list ONE by ONE,
> buy, within Swing, I can't find the method that allow me to add data
> item one by one tomy JList or
> JCombobox???
> 
> ...
> JList jList1 = new JList();
> ..
> 
> for (i = 0; i < Student_Name.length; i++) {
>     jList1.add( Student_Name[i]);
>    ^^^^^^^^^^^^^
> }
> ....
> 
> Because the content of  Student_Name[] is not fixed, so I can't use "
> new JList(Student_Name[])" to
> do this,  I have to add the data item one by one.....
> 
> PLEASE HELP ME............. THANKS SO MUCH!!!
> 
> ERic
Technical Details
Message-ID: <3822D49E.5645F476@isys-group.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3822B46C.BCC06F27@usa.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,5598d06099a399b3
X-Google-Attributes: gid111d45,public
From: Gerry Stechow <stechow@isys-group.de>
Subject: Re: Please Help ME...(Problem about JList & JCombobox)
Date: 1999/11/05
Message-ID: <3822D49E.5645F476@isys-group.de>
X-Deja-AN: 544790922
Content-Transfer-Encoding: 7bit
References: <3822B46C.BCC06F27@usa.net>
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