0

我正在做一个百万欧元的计划,我需要一些帮助。我有这段代码,我想为 JButton 设置一个大小。我不知道该怎么做

有人可以告诉我我需要改变什么吗?

static JButton[][] botoes = new JButton[5][10];
static JButton [][] estrelas = new JButton[4][3];

public void grafica(){
    GridLayout layoutBotoes = new GridLayout(5,10);
    GridLayout layoutEstrelas = new GridLayout(4,3);
    um.setLayout(layoutBotoes);
    dois.setLayout(layoutEstrelas);
    for(i=0;i<5;i++){  
        for(l=0;l<10;l++){  
            cont++;
            botoes[i][l] = new JButton(""+cont);
            um.add(botoes[i][l]); 
            botoes[i][l].addActionListener(this);
        } 
    }  
    cont=0;
    for(i=0;i<4;i++){  
        for(l=0;l<3;l++){ 
            if(i==3 && l==2) {
                break;
            } else {
                cont++;
                estrelas[i][l] = new JButton(""+cont); 
                dois.add(estrelas[i][l]); 
                estrelas[i][l].addActionListener(this);
            }
        }
    }
}
4

1 回答 1

1

您也许可以使用此处此处显示的方法之一。

图片

于 2013-04-14T11:41:38.497 回答