Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2012, 05:47 AM
javagos javagos is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 javagos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 27 sec
Reputation Power: 0
[Assignment/Homework] Problem with concatenation/Text Fields

Hello, I'm new and just need this problem fixed, and have no idea how to do it.

I have several text fields and am trying to put an integer (from a two-dimensional array) into them.

The name of the text fields have "jtf" and then two numbers corresponding to what the numbers are in the 2D array.

I am trying to do this using a for loop, here is an example of what I have:
Code:
    p1.add(jtf00 = new JTextField(""));
    p1.add(jtf01 = new JTextField(""));
    p1.add(jtf02 = new JTextField(""));
    p1.add(jtf03 = new JTextField(""));
    p1.add(jtf10 = new JTextField(""));
    p1.add(jtf11 = new JTextField(""));

for (int i = 0; i < gameGrid.buttonarray.length; i++)
{
  for (int j = 0; j < gameGrid.buttonarray.length; j++)
  {
     String temp = "jtf" + i + "" + j;                    
     <___>.setText(Integer.toString(gameGrid.buttonarray[i][j]));
  }
}


I'm not sure what to put in <___> and I'm not even sure if there is such code for it. I am trying to concatenate the "jtf" with "i" and "j" which will change the value in the 2D array as well, however a text field name needs to go in the <___> area and as you can see I tried to make a new String with the text field name, but temp.setText(Integer.toString(gameGrid.buttonarray[i][j])); doesn't work because it is trying to get something from the String class.

Any help would be appreciated!

Last edited by javagos : October 25th, 2012 at 07:05 AM. Reason: Wrong Title

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Need quick/easy help for a small project.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap