title: Java: I can't change the background of JButton
body: <p>Greeting everyone. I've working a java program. I want to change the background of a JButton,However I can't change it. When the function is over, the color doesn't change a little.Here is my Code:</p>
  
  <pre><code>public void initialization() {
          button = new JButton[size][size];
          mainPanel.setLayout(new GridLayout(0, size));
          for (int i = 0; i &lt; size; i++) {
              for (int j = 0; j &lt; size; j++) {
                  button[i][j] = new JButton();
                  button[i][j].setBackground(Color.BLACK);
                  //button[i][j].setVisible(true);
                  //button[i][j].setEnabled(false);
                  mainPanel.add(button[i][j]);
  
              }
          }
          mainPanel.updateUI();
          System.out.print("Button Finished\n");
      }
  </code></pre>
  
  <p>I hope someone can help me.</p>