• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Two Questions  RSS feed

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)
I want to populate a JComboBox with integer data from a for loop.
e.g
for(int day =1; day <= 31; day++)
{
comboDay = new JComboBox(day);
}
To my understanding, the argument should be of type string.
How do I do that.
2) When using Applets, getAppletContext().showStatus() is used to display data at the bottom of the Applet. How can this be achieved using Frames.
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) The static method String.valueOf(int) will convert an int into a String; there are overloaded versions of this method for all the Java primitive types.
The "for" loop you've shown will create 31 combo boxes, which I don't think is what you want; you could do something like this instead:

2) If you add a JLabel to the bottom of your JFrame, then calling thatLabel.setText() will be roughly equivalent to calling showStatus() in an applet.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In the first case, try this one:
Interger dag;
for(int day=1; day<=31; day++)
{
dag = new Interger(day);
comboDay = new JComboBox(dag.toString());
}
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Patrick,
1) The argument to JComboBox should not be of type string - rather it should be an Object.
2) I use to add a Panel with Bevel Border containing a Label(static variable), to the SOUTH of the Frame - the label is to show the messages.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!