JLabel in GridLayout
问题 How to add JLabel out of the GridLayout ? I have an 8x8 grid layout. Container content = getContentPane(); content.setLayout(new GridLayout(8, 8,2,2)); for (int f = 0; f < btnArr.length; f++){ for (int s = 0; s < btnArr.length; s++){ btnArr[f][s] = new JButton(); btnArr[f][s].addActionListener(this); content.add(btnArr[f][s]); btnArr[f][s].setBackground(randomColor()); } } 回答1: import java.awt.*; import javax.swing.*; class SimpleNestedLayout { public static void main(String[] args) {