TeamJava Forum

[ Read Responses | Post a New Response | Return to the Index ]
[ Previous | Next in Thread | Next ]


Create storage for the list of phrases - arrays HELP?!

Posted by Rob on Saturday, 26 July 2003, at 4:46 p.m.

I am lost with these instructions(at the bottom) - I have the first part where I have instance variables which hold an array named "display" and initiated ao ALabels for output put I can't get any further. Here's what I have so far:

public class ListOfStrings extends A3ButtonHandler
{

private A3ButtonWindow win;
private ATextField input;
private ALabel entries;
private ALabel answer;
private ALabel[] display; // Declares a variable that can hold an array

/**
* Constructs the handler object, the 3-button
* window and populates the window.
*/
public ListOfStrings()
{

// Create the 3-button window
win = new A3ButtonWindow(this);
win.setLeftText("Save");
win.setMidText("Display");
win.setRightText("Discard");

display = new ALabel[10];
display[0] = new ALabel(200, 100, 200, 20); // Populate first element
display[1] = new ALabel(200, 125, 200, 20);
display[2] = new ALabel(200, 150, 200, 20);
display[3] = new ALabel(200, 175, 200, 20);
display[4] = new ALabel(200, 200, 200, 20);
display[5] = new ALabel(200, 225, 200, 20);
display[6] = new ALabel(200, 250, 200, 20);
display[7] = new ALabel(200, 275, 200, 20);
display[8] = new ALabel(200, 300, 200, 20);
display[9] = new ALabel(200, 325, 200, 20);
display[9] = new ALabel(200, 350, 200, 20); // Populate tenth element

input = new ATextField(125, 400, 150, 25);
input.place(win);

// Refresh the window
win.repaint();
}

Create storage for the list of phrases.
The core of this program maintains a list of string values that are input by the user. In this step, you will create the storage for the list. This consists of two parts: an array that can contain up to 10 String objects and an integer that will show how many objects in the array are in the list.

Declare instance variables for the list, that is, the array of Strings and the count of items in the list. Name them something descriptive, like storage and count.
In the constructor, create the array and initialize the count to zero.
There is no reason to fill the array. Since the count is zero, we know not to access values within the array. There is no visible change based on this step.


Responses


Post a New Response

Please select: Discussion Question Answer
Pulse Check - enter num: 1068085685

Your Name:

E-Mail Address:

Subject:

Message:


If you'd like to include a link to another page with your message,
please provide both the URL address and the title of the page:

Optional Link URL:

Optional Link Title:


If you'd like to have the option of deleting your post later,
please provide a password (CASE SENSITIVE!):

Password:



Password:

The TeamJava Forum is maintained with WebBBS 2.24.


TeamJavaHome | Ind. Registry | Co. Registry | Java Links
Jobs Listings Forum | TeamJava Books | Java FAQ Archives

AWN

Copyright © 1995-2003 Active Web Networks, all rights reserved.
(Note: We share no direct association with Sun Microsystems, Inc.)