Solved

Combo items

Posted on 2000-05-18
4
201 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB Script to add site to Java Exception List 4 76
eclipse shortcuts 9 55
spring jars download 1 27
jsp login check 12 31
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

770 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