Solved

Combo items

Posted on 2000-05-18
4
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example 11 59
pagenation logic how it is working in my code 1 71
servlet and mdb, jms error 1 57
junit as external jar or library 7 40
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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:

730 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