2015-04-04 54 views
-2
ImageIcon img_1 = new ImageIcon("src/menu/btn_1.jpg"); 
    ImageIcon img_2 = new ImageIcon("src/menu/btn_2.jpg"); 
    ImageIcon img_3 = new ImageIcon("src/menu/btn_3.jpg"); 
    ImageIcon img_4 = new ImageIcon("src/menu/btn_4.jpg"); 
    ImageIcon img_5 = new ImageIcon("src/menu/btn_5.jpg"); 
    ImageIcon img_6 = new ImageIcon("src/menu/btn_6.jpg"); 
    ImageIcon img_7 = new ImageIcon("src/menu/btn_7.jpg"); 
    ImageIcon img_8 = new ImageIcon("src/menu/btn_8.jpg"); 
    ImageIcon img_9 = new ImageIcon("src/menu/btn_9.jpg"); 

    bgNumbers = new ButtonGroup(); 
    btnNumbers = new JToggleButton[9]; 
    for (int i = 0; i < 9; i++) { 
     btnNumbers[i] = new JToggleButton(???); 
     ..... 
     ..... 
    } 

如何將個人ImageIcon img_1,img_2 ....... img_9插入循環?創建多個JToggleButton與個人ImageIcon

+0

將它們添加到數組而不是單個變量。 – 2015-04-04 07:35:45

回答

0

將它們添加到數組而不是單個變量。 - GáborBakos 4月4日7:35