Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Arrays - New User Help!

Status
Not open for further replies.

owls

Instructor
Oct 10, 2002
23
0
0
US
I am a new user of Java using JBuilder. I am trying to create an array of labels using the design view in JBuilder but there doesn't seem to be a way to do it. In visual basic if you copied and pasted an object it automatically created an array for you. JBuilder does not do it though. Also I have tried creating the array in the source code, but it seems that whenever I try to create objects in code in a class that was designed by JBuilders wizards, they don't appear in the design view.

Can anyone tell me if there is a way to create an array using JBuilders tools?, and can I create applications using both the design view and source code?
 
Hi owls:

I really don't know how to do that (I think that you can't), but, what I do is to design the view in JBuilder to avoid the layout calculations and then change the generated code to fit my needs.

Hope it helps. Pedro Andrés Solorzano
Pontificia Universidad Javeriana
Bogotá, Colombia, SurAmérica.
 
Thanks for the response. I have tried editing the code after creating my initial GUI with JBuilder but my objects don't appear in the design view. I am doing the following editing in code to add an array of labels. Could you tell me if I need to do anything else to see these labels in the design view.

//instantiation of array
JLabel[] myLabelArray = new JLabel[5];

// Setting some text to my labels to differentiate them
for(int i = 0; i<5;i++)
{
array.setText(&quot;jLabel&quot; + i);
array.setVisible(true);
}

// Adding array to content pane
for(int i = 0; i<5;i++)
{contentPane.add(myLabelArray, new XYConstraints(53,18,70, 44));}
}
 
One tip, the for loop needs to go until the end of the array. You can change the 5 in the loop with myLabelArray.length.
If you change the length later you don't have to adjust all the loops.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top