No, you can't add components at a specific cell. What you can do is add empty JPanel objects and hold on to references to them in an array, then add components to them in any order you want.
Something like:
int i = 3;
int j = 4;
JPanel[][] panelHolder = new JPanel[i][j];
setLayout(new GridLayout(i,j));
for(int m = 0; m < i; m++) {
for(int n = 0; n < j; n++) {
panelHolder[m][n] = new JPanel();
add(panelHolder[m][n]);
}
}
Then later, you can add directly to one of the JPanel objects:
panelHolder[2][3].add(new JButton("Foo"));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…