title: Adding buttons into a java game
body: <p>How can I add a button to this code so it makes the text that say Play, Highscore and Exit into actual buttons, so when someone clicks it it does the thing they want it to do.    </p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  class MainPanel extends JPanel {
  
      public void paintComponent(Graphics g)
      {
  
          //EkansBackground
          g.setColor(Color.BLACK);
          g.fillRect(50, 50, 600, 400);
  
          //EkansLogo
          g.setColor(Color.WHITE);
          int fontSize = 50;
          Font f = new Font("Marker felt", Font.BOLD, fontSize);
          g.setFont(f);
          g.drawString("---] EKANS [---", 180, 200);
  
          //Play button
          g.setColor(Color.GREEN);
          int fontSize1 = 40;
          Font f1 = new Font("comic sans ms", Font.ITALIC, fontSize1);
          g.setFont(f1);
          g.drawString("&gt; PLAY &lt;", 270, 280);
  
          //Play button
          g.setColor(Color.RED);
          g.drawString("&gt; EXIT &lt;", 270, 380);
  
          //High Score button
          g.setColor(Color.BLUE);
          g.drawString("&gt; High Scores &lt;", 215, 330);
  
  
      }
  }
  </code></pre>