View Single Post
  #2 (permalink)  
Old 02-17-2008, 12:42 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,189
hardwired is on a distinguished road
Code:
// This only/merely allocates an array of JButtons. // Each element of the array is null. JButton[][] slots = new JButton[6][7]; for(int i = 0; i < slots.length; i++) { for(int x = 0; x < slots[i].length; x++) { int n = i*slots[i].length + x+1; // Instantiate each element of the array. // Try this with and without this line. slots[i][x] = new JButton(String.valueOf(n)); if(slots[i][x] == null) System.out.println("slots["+i+"]["+x+"] = " + slots[i][x]); else System.out.println("slots["+i+"]["+x+"].text = " + slots[i][x].getText()); } }
Reply With Quote