How to debug this java code ? What is the error in this code?
<pre><code>import javax.swing.*; // For JPanel, etc.
import java.awt.*;           // For Graphics, etc.
import java.awt.geom.*;      // For Ellipse2D, etc.
import java.awt.event.*; 


public class ShapeExample extends JPanel {
  private Rectangle2D.Double square =
    new Rectangle2D.Double(50, 50, 100, 100);
  private Rectangle2D.Double square1 =
    new Rectangle2D.Double(10, 10, 200, 200);

  public void paintComponent(Graphics g) {
    clear(g);
    Graphics2D g2d = (Graphics2D)g;
    g2d.fill(square);
    g2d.draw(square1);
  }
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
    b.setActionCommand("Good Morning"); 
    b.addActionListener(a); 
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
    b.addActionListener(a); 
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
    b.setActionCommand("Exit"); 
    b.addActionListener(a); 
    g.pack(); 
    g.show(); 
} 
  // super.paintComponent clears offscreen pixmap,
  // since we're using double buffering by default.

  protected void clear(Graphics g) {
    super.paintComponent(g);
  }

  protected Rectangle2D.Double getsquare() {
    return(square);
  }

  public static void main(String[] args) {
    WindowUtilities.openInJFrame(new ShapeExample(), 100, 100);
    Button b; 

  }
}
</code></pre>

<p>How to debug this code?</p>

<p>The error I get is this </p>

<pre><code>ShapeExample.java:19: &lt;identifier&gt; expected
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
      ^
ShapeExample.java:19: &lt;identifier&gt; expected
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
        ^
ShapeExample.java:19: ';' expected
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
          ^
ShapeExample.java:19: invalid method declaration; return type required
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
               ^
ShapeExample.java:19: illegal start of type
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
                      ^
ShapeExample.java:19: ';' expected
 g.add(b = new Button("Bonjour"), BorderLayout.NORTH); 
                                ^
ShapeExample.java:20: &lt;identifier&gt; expected
    b.setActionCommand("Good Morning"); 
                      ^
ShapeExample.java:20: illegal start of type
    b.setActionCommand("Good Morning"); 
                       ^
ShapeExample.java:21: &lt;identifier&gt; expected
    b.addActionListener(a); 
                       ^
ShapeExample.java:21: &lt;identifier&gt; expected
    b.addActionListener(a); 
                         ^
ShapeExample.java:22: &lt;identifier&gt; expected
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
         ^
ShapeExample.java:22: &lt;identifier&gt; expected
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
           ^
ShapeExample.java:22: ';' expected
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
             ^
ShapeExample.java:22: invalid method declaration; return type required
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
                  ^
ShapeExample.java:22: illegal start of type
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
                         ^
ShapeExample.java:22: ';' expected
    g.add(b = new Button("Good Day"), BorderLayout.CENTER); 
                                    ^
ShapeExample.java:23: &lt;identifier&gt; expected
    b.addActionListener(a); 
                       ^
ShapeExample.java:23: &lt;identifier&gt; expected
    b.addActionListener(a); 
                         ^
ShapeExample.java:24: &lt;identifier&gt; expected
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
         ^
ShapeExample.java:24: &lt;identifier&gt; expected
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
           ^
ShapeExample.java:24: ';' expected
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
             ^
ShapeExample.java:24: invalid method declaration; return type required
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
                  ^
ShapeExample.java:24: illegal start of type
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
                         ^
ShapeExample.java:24: ';' expected
    g.add(b = new Button("Aurevoir"), BorderLayout.SOUTH); 
                                    ^
ShapeExample.java:25: &lt;identifier&gt; expected
    b.setActionCommand("Exit"); 
                      ^
ShapeExample.java:25: illegal start of type
    b.setActionCommand("Exit"); 
                       ^
ShapeExample.java:26: &lt;identifier&gt; expected
    b.addActionListener(a); 
                       ^
ShapeExample.java:26: &lt;identifier&gt; expected
    b.addActionListener(a); 
                         ^
ShapeExample.java:27: &lt;identifier&gt; expected
    g.pack(); 
          ^
ShapeExample.java:28: &lt;identifier&gt; expected
    g.show(); 
          ^
ShapeExample.java:33: class, interface, or enum expected
  protected void clear(Graphics g) {
            ^
ShapeExample.java:35: class, interface, or enum expected
  }
  ^
ShapeExample.java:39: class, interface, or enum expected
  }
  ^
ShapeExample.java:41: class, interface, or enum expected
  public static void main(String[] args) {
                ^
ShapeExample.java:43: class, interface, or enum expected
    Button b; 
    ^
ShapeExample.java:45: class, interface, or enum expected
  }
</code></pre>

<p>how to debug this?</p>
