title: Refresh panel when a button in clicked
body: <p>I have a MainPanel containing 2 other panels(show random number) and a Next Button. When I click the next button, I want to show another combination of numbers. I'm unable to achive that.</p>
  
  <p>I'm average in swing. I know how to use Panel, Button and Listener(not sure). But how to link them no!!!.   </p>
  
  <p>My Code:</p>
  
  <pre><code>public class Test extends JFrame implements MouseListener {
  
  
    JPanel mainPanel = new JPanel(new GridLayout(1, 1, 5, 5));
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    JLabel label1 = new JLabel();
    JLabel label2 = new JLabel();
    JPanel buttonPanel = new JPanel();
    JButton next = new JButton();
  
  public void randomNumber(){
      int randomNumber1 = 0;
      int randomNumber2 = 0;
      randomNumber1 = 1 + (int) (Math.random() * 9);
      randomNumber2 = 1 + (int) (Math.random() * 9);
  
      label1.setText(String.valueOf(randomNumber1));
      label2.setText(String.valueOf(randomNumber2));        
  }
  
  
  public Test(){
  
     panel1.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
     panel2.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
     panel1.setBackground(Color.red);
     panel2.setBackground(Color.yellow);    
  
     panel1.add(label1);
     panel2.add(label2);       
  
     next.setText("Next");
  
     mainPanel.add(panel1);
     mainPanel.add(panel2);
     buttonPanel.add(next);
  
     this.add(mainPanel, BorderLayout.NORTH);
     this.add(buttonPanel,BorderLayout.CENTER);
  
     initUI();
  }
  
  /**
   *
   */
  public final void initUI()
  {
      setTitle("Test");
      setSize(800, 400);
      setLocationRelativeTo(null);
      setVisible(true);
      this.setResizable(false);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  
  public void actionPerformed(ActionEvent event) {
  Object source = event.getSource();
    if (source instanceof JButton) randomNumber()  ;
  }
  
  
  /**
   *
   * @param args
   */
  public static void main(String[] args){
        Test game = new Test();
        game.setVisible(true);
      }    
  </code></pre>
  
  <p>}</p>