Results 1 to 5 of 5
  1. #1
    gbonecapone is offline Member
    Join Date
    May 2013
    Posts
    68
    Blog Entries
    1
    Rep Power
    0

    Default using a for loop to control text boxes

    Hey java world.. i ran into a situation when i have a bunch of columns and rows of text boxes.


    here is an example of their names:
    Java Code:
    cut1.setVisible(false);
                     seq1.setVisible(false);
                     xdim1.setVisible(false);
                     yrdim1.setVisible(false);
                     yldim1.setVisible(false);
              
                    cut2.setVisible(false);
                     seq2.setVisible(false);
                     xdim2.setVisible(false);
                     yrdim2.setVisible(false);
                     yldim2.setVisible(false);
            
                    cut3.setVisible(false);
                     seq3.setVisible(false);
                     xdim3.setVisible(false);
                     yrdim3.setVisible(false);
                     yldim3.setVisible(false);
      
                    cut4.setVisible(false);
                     seq4.setVisible(false);
                     xdim4.setVisible(false);
                     yrdim4.setVisible(false);
                     yldim4.setVisible(false);
         
                    cut5.setVisible(false);
                     seq5.setVisible(false);
                     xdim5.setVisible(false);
                     yrdim5.setVisible(false);
                     yldim5.setVisible(false);
              
                    cut6.setVisible(false);
                     seq6.setVisible(false);
                     xdim6.setVisible(false);
                     yrdim6.setVisible(false);
                     yldim6.setVisible(false);
                 
                    cut7.setVisible(false);
                     seq7.setVisible(false);
                     xdim7.setVisible(false);
                     yrdim7.setVisible(false);
                     yldim7.setVisible(false);
    i made them this way because i have 50 rows. (each chunk of text boxes is a row) the user is going to write in an intial text box to state how many rows he/she wants.
    i orginally planned on writing something like this to make it easier on controlling them.


    Java Code:
    //num = user input
    
      for (int i = 1; i <= num; i++) {
    
    cut+i+.setVisible(true);
                     seq+i+.setVisible(true);
                     xdim+i+.setVisible(true);
                     yrdim+i+.setVisible(true);
                     yldim+i+.setVisible(true);
    }
    that didnt work haha
    is there a way to do it with arrays or strings?
    i also tried to do that a little bit but i was having problems because it didnt recognize the string as a text box. im trying to be more efficient because i have to do it multiple times and changing 250 text boxes 1 by 1 its starting to blow.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: using a for loop to control text boxes

    Nope, and it won't either. Try using a Map.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: using a for loop to control text boxes

    Quote Originally Posted by gbonecapone View Post
    i have a bunch of columns and rows of text boxes.
    Sounds like you should be using a JTable.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    gbonecapone is offline Member
    Join Date
    May 2013
    Posts
    68
    Blog Entries
    1
    Rep Power
    0

    Default Re: using a for loop to control text boxes

    i like the idea of a jtable, is there a way to make the number of rows and columns user submitted?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: using a for loop to control text boxes

    Quote Originally Posted by gbonecapone View Post
    i like the idea of a jtable, is there a way to make the number of rows and columns user submitted?
    Yes.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Java text boxes does not show
    By zAxOanL in forum New To Java
    Replies: 0
    Last Post: 03-25-2012, 04:08 AM
  2. Replies: 2
    Last Post: 08-11-2011, 05:02 PM
  3. Get text from multiple text boxes/tables
    By greenhorn in forum New To Java
    Replies: 0
    Last Post: 03-08-2011, 03:32 PM
  4. Retrieve values of Text boxes using LIST
    By Kayal in forum Web Frameworks
    Replies: 2
    Last Post: 03-20-2009, 11:00 AM
  5. Replies: 2
    Last Post: 01-23-2009, 04:09 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •