title: Draw Shapes That User Selects
body: <p>I need to create a program to draw shapes(user chooses with radio button), and whether or not the shape is filled(user chooses with check box). This is the code I have so far:</p>
  
  <pre><code> import javax.swing.*;
   import java.awt.*;
   import java.awt.event.*;
  
  public class SelectShape extends JFrame implements ItemListener{
      private JRadioButton line = new JRadioButton("Line");
      private JRadioButton rect = new JRadioButton("Rectangle");
      private JRadioButton oval = new JRadioButton("Oval");
      private JCheckBox fill = new JCheckBox("Filled");
      private FigurePanel fp;
  
  
  public static void main(String[] args) {
      SelectShape frame = new SelectShape();
      frame.setTitle("Select Shape");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationRelativeTo(null);
      frame.setSize(400,400);
      frame.setVisible(true);
  }
  
  public SelectShape() {
      JPanel p1 = new JPanel();
      p1.add(fp);
      fp.setBackground(Color.WHITE);
      p1.setSize(200,400);
  
      JPanel p2 = new JPanel();
      p2.setLayout(new FlowLayout());
      p2.add(line);
      p2.add(rect);
      p2.add(oval);
      p2.add(fill);
      add(p2, "South");
  
      line.addItemListener(this);
      rect.addItemListener(this);
      oval.addItemListener(this);
      fill.addItemListener(this);
  
  }
  
  public void ItemStateChanged(ItemEvent e) {
      if(rect.isSelected()) {
          FigurePanel.dRect();
          repaint();
      }
      else if(oval.isSelected()) {
          FigurePanel.dOval();
          repaint();
      }
      else if(line.isSelected()) {
          FigurePanel.dLine();
          repaint();
      }
      if(fill.isSelected()) {
          FigurePanel.fill();
          repaint();
      }
      else {
          FigurePanel.erase();
          repaint();
      }
  }       
  }
  
  class FigurePanel extends JPanel {
  public void paintComponent(Graphics g) {
      super.paintComponent(g);
      public void dLine(Graphics g) {
          g.drawLine(10,10,160,10);
      }
      public void dRect(Graphics g) {
          g.drawRect(10,10,150,50);
      }
      public void dOval(Graphics g) {
          g.drawOval(10,10,150,50);
      }
  
      public void fill(Graphics g) {
          g.setColor(Color.GREEN);
          if(rect.isSelected()) {
              g.fillRect(10,10,150,50);
          }
          else if(oval.isSelected()) {
              g.fillOval(10,10,150,50);
          }
      }
      public void erase(Graphics g) {
          g.setColor(Color.WHITE);
          if(rect.isSelected()) {
              g.fillRect(10,10,150,50);
          }
          else if(oval.isSelected()) {
              g.fillOval(10,10,150,50);
          }
      }
  }
  }
  </code></pre>
  
  <p>The errors I am getting are illegal start of expression and identifier expected. If I should approach this another way, please tell. </p>