Array that Holds JButton Objects

前端 未结 4 1614
情歌与酒
情歌与酒 2020-12-10 19:08

Ok, so I\'m attempting to do an exercise from a book I\'m using to learn Java. Here is the code that I have so far:

import javax.swing.*;
import java.awt.Gri         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 19:38

    If I understand your problem, you need the loop to instantiate and store the JButtons.

    for (int i=0; i<10; i++) {
        numButton[i] = new JButton(String.valueOf(i));
    }
    

    You need to convert the loop control variable into a String argument for the JButton constructor.

提交回复
热议问题