Solved

Combo items

Posted on 2000-05-18
4
202 Views
Last Modified: 2010-08-05
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
Comment
Question by:spunog
  • 2
4 Comments
 
LVL 3

Expert Comment

by:ovidiucraciun
ID: 2821291
can you be more specific, please explain in more words...
0
 
LVL 2

Accepted Solution

by:
shchuka earned 50 total points
ID: 2821303
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
 
LVL 2

Expert Comment

by:Veroland
ID: 2821318
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
 
LVL 2

Expert Comment

by:Veroland
ID: 2821321
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to install java on RHEL image on EC2 4 39
mysql jsp example issue 32 48
ejb entity bean example 2 7
ejb mdb examples 1 6
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question