Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Two Questions  RSS feed

 
Patrick Mugabe
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.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
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.
 
Sbusiso Nhlumayo
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());
}
 
VIJAY Yadlapati
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!