🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Jcombobox and numbers

#1421
From: Lori M Olson (TeamB)
Date: Sun, 09 Nov 2003 22:49
39 lines
2075 bytes
tz wrote:
> Please someone give me some sample code to add numbers in jcombobox. This is
> my code:
>   void cmbCalendar_actionPerformed(ActionEvent e) {
>    String s =  (String) cmbYear.getSelectedItem();
>    if (s.equals("Gregorian"))
>    {
>      for (int x = 1583; x < 2501; x++)
>      {
>        cmbYear.addItem((String) (x));
>      ...............
> The above line is erroring out. Can someone tell me how to correct this with
> a code sample?
> thanks.
> 
> 

Why add stuff as strings, when you really want to be dealing with numbers?

cmbYear.addItem( new Integer(x) );

-- 

Regards,

Lori Olson (TeamB)

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
     http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
     http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
     http://www.visi.com/~gyles19/fom-serve/cache/1.html
Technical Details
Message-ID: <3faec463$2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fae5464$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,a319fdba4750032b
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2003-11-09 15:09:13 PST
Date: Sun, 09 Nov 2003 15:49:08 -0700
From: "Lori M Olson (TeamB)" <javadragon@techie.com>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1
X-Accept-Language: en-ca, en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Jcombobox and numbers
References: <3fae5464$1@newsgroups.borland.com>
In-Reply-To: <3fae5464$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 142.179.181.200
Message-ID: <3faec463$2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1068418147 142.179.181.200 (9 Nov 2003 14:49:07 -0700)
Lines: 40
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail