Results 1 to 2 of 2
  1. #1
    jumpgirl is offline Member
    Join Date
    Mar 2012
    Posts
    18
    Rep Power
    0

    Default Problems inserting 1d array to 2d array grid

    I have this code where I generate random letters and 25% of it should be vowels. This part works well but I can't insert it to my grid. I used GridBagLayout for my grid.
    This code only displays the topmost part of the array and I can't figure out how to display all the contents of my array to the grid. Please someone check my code

    Java Code:
    		
    		//add to grid
    		int i = 0;
    		int j = 0;
    		String s = null;
    		char c2 = 0;
    		
    		for(i = 1; i<11; i++){
    			for(j = 1; j<11; j++){
    				
    				//char c1 = (char)(rand.nextInt('Z'-'A' +1) + 'A');				
    				
    				//String s = "" + c1;
    				//arr.add(s);
    
    				for(int k = 0; k < 100; k++){
    					c2 = arr3[k];
    					s = "" + c2;
    					System.out.println(s);	
    
    				}
    							
    				box[i][j] = new JTextField(s);
    	
                	box[i][j].setHorizontalAlignment(JTextField.CENTER);
                	c.gridx = i;
                	c.gridy = j; 	
                	c.ipadx = 40;
                	c.ipady = 35;
                	c.insets = new Insets(10,10,5,5);
                	box[i][j].setEditable(false);
                
                	c.anchor = GridBagConstraints.NORTHWEST;	
                	pane.add(box[i][j], c);				
    			}
    			
    		}
    Last edited by jumpgirl; 03-26-2012 at 02:35 AM.

  2. #2
    jumpgirl is offline Member
    Join Date
    Mar 2012
    Posts
    18
    Rep Power
    0

    Default Re: Problems inserting 1d array to 2d array grid

    nvm solved it.

Similar Threads

  1. 2d array grid
    By rjsupaflea in forum New To Java
    Replies: 14
    Last Post: 06-07-2011, 02:47 AM
  2. inserting values in to array
    By Dayanand in forum New To Java
    Replies: 8
    Last Post: 03-05-2011, 04:23 PM
  3. Need help with inserting a new number into an array
    By Get_tanked in forum New To Java
    Replies: 7
    Last Post: 01-21-2011, 02:36 AM
  4. Replies: 6
    Last Post: 11-03-2010, 02:33 PM
  5. Replies: 2
    Last Post: 09-06-2010, 01:03 AM

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
  •