• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Combo items

How do I read in strings from a text file, one digit on each line and use the digit to choose Choices in Combo options(drop down menus) I think that say theres 6 choices in each one so 0 would indicate choose the first and so on .Any ideas ?
Thanks in advance
0
spunog
Asked:
spunog
  • 2
1 Solution
 
ovidiucraciunCommented:
can you be more specific, please explain in more words...
0
 
shchukaCommented:
Well, you can use BufferedReader to read the lines of text and then convert them into integers - something like this:

import java.io.*;

int chNum;

try {
    BufferedReader br = new BufferedReader(new FileReader(filename));
    chNum = Integer.valueOf(br.readLine()).intValue();
    // You can read the rest of the lines here beyond the first one
}
catch(IOException ex) {
    // errors with the file
}
catch(NumberFormatException ex) {
    // what you read is not a number
}


And then you simply do this:

Choice combobox = new Choice();
....
combobox.select(chNum);


Hope, this helps,
-Aleks.
0
 
VerolandCommented:
File fin = new File("Filename");
BufferedInputStream bIn = new BufferedInputStream(fsIn);
BufferdReader brIn = new BufferedReader(new InputStreamReader(bIn));

String str = new String();
str = brIn.readln();
int s = dd.intValue(str);

combo1.getItemAt(s.intValue);

This is just a rough example, if you need more detail let me know


0
 
VerolandCommented:
opps, supposed to look like this:

String str = new String();
str = brIn.readln();
Long dd = new Long(str);
int s = dd.intValue();

combo1.getItemAt(s.intValue);
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now