Hello, I can't see the forest through the trees on this. Can someone help me? The instructions are this: This program can display up to 10 phrases (String values) in 10 different ALabel objects. To make working with the display easier, the ALabel objects will be accessed using an array. Declare an instance variable which will hold an array of ALabel references. Name it something descriptive, like display. In the constructor, instantiate 10 ALabel objects for output. Each of these objects will have size (200, 20). Their locations are (200, 100), (200, 125), (200, 150), ... (200, 325). Set the fontSize property of these objects to 12 to make them easier to read. Place the label objects in the window. By default, the value of the text property is the empty string. So, they will start out �invisible�. Test your application. Verify that the window layout is what you expect. Remember that you will need to override the leftAction, midAction, and rightAction methods to compile this class. Any help would be greatly appreciated PS I have this so far:
Declare an instance variable which will hold an array of ALabel references.
Instance variables are those variables you declare at the beginning of your class (not inside a method). These are the variables that are created for each instance of the object. So, let's do that:
Okay, now you've got an instance variable named display. It's a private array of ALabels. Actually, it's only a variable that can hold an array - you haven't even created the array yet. Right now, display has null in it. Next, the instructions say to populate the array in the constructor.
In the constructor, instantiate 10 ALabel objects for output. Each of these objects will have size (200, 20). Their locations are (200, 100), (200, 125), (200, 150), ... (200, 325).
Here's the most straightforward way (you had the right idea to start):
First, I created an array of 10 elements of type ALabel. However, the array is empty; that is, each of the elements contains null. Then, I filled each individual element with a new ALabel. Other options would be to initialize the array when I create it (this syntax is a little more copmlex), or since the values follow a set pattern, I could have used a simple for loop. But either of those I think are a little more than you asked for. Note that I didn't set the font size to 12 as the instructions said; I'll leave that to you. However, the fact that you have to do the same operation on each element makes a for loop an attractive option. Hope this helps! Joe
Wow I am printing that out.... I know how to set the font size etc... I appreciate it! Thanks you so much! It is really strange that I see it and it makes sense - I sometimes sike myself out I think. Rob
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth