Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

storing input from an applet into an array

Posted on 2003-03-14
4
Medium Priority
?
176 Views
Last Modified: 2011-09-20
I have to create an applet where i have two different text fields and need to store the input from each field into an array. Please help!!! Also, how can i initialize the number of elements in the array just from the number of times the user clicks the "enter" button?
0
Comment
Question by:mars0037
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 8139989
String[] entered = new String[] { tf1.getText(), tf2.getText() };

> how can i initialize the number of elements in the array
> just from the number of times the user clicks the "enter" button?

Object[] myaaray = new Object[ntimes];



0
 
LVL 2

Expert Comment

by:Snurre
ID: 8139999
Hi...

Try to do the following things...

TextField t = new TextField();
String Test[] = new String[50];

in the main()

Test[0] = t.getText();

This is the easy way of doing it... :o)

And about the User 'ENTER' press, try with an int that keeps track of the number of times the 'ENTER' button been pressed...
0
 
LVL 3

Accepted Solution

by:
wide_awake earned 750 total points
ID: 8141105
Another option is to use a Vector instead of an array, that way you can use Vector.add(text) instead of specifying a fixed-size array.

-mark.
0
 

Author Comment

by:mars0037
ID: 8141443
i think i'll try the vector. thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

564 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