Thread View: borland.public.jbuilder.java.swing
4 messages
4 total messages
Started by tz
Sun, 09 Nov 2003 14:51
Jcombobox and numbers
Author: tz
Date: Sun, 09 Nov 2003 14:51
Date: Sun, 09 Nov 2003 14:51
13 lines
1244 bytes
1244 bytes
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.
Re: Jcombobox and numbers
Author: tz
Date: Sun, 09 Nov 2003 15:06
Date: Sun, 09 Nov 2003 15:06
22 lines
1615 bytes
1615 bytes
String s = (String) cmbYear.getSelectedItem(); is really String s =
(String) cmbCalendar.getSelectedItem();
"tz" <teddybubu@hotmail.com> wrote in message
news:3fae5464$1@newsgroups.borland.com...
> 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.
>
>
Re: Jcombobox and numbers
Author: Lori M Olson (TeamB)
Date: Sun, 09 Nov 2003 22:49
Date: Sun, 09 Nov 2003 22:49
39 lines
2075 bytes
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
Re: Jcombobox and numbers
Author: tz
Date: Mon, 10 Nov 2003 08:24
Date: Mon, 10 Nov 2003 08:24
45 lines
2152 bytes
2152 bytes
Thanks Lori.
"Lori M Olson (TeamB)" <javadragon@techie.com> wrote in message
news:3faec463$2@newsgroups.borland.com...
> 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
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads