title: How would you get a switch statement in Java to print out on a GUI?
body: <p>I want to make a magic 8 ball kind of program but, I don't know how to get the switch case statement to print out on a GUI. I'm not really sure what to do from here. I tried looking in my java books and the internet but, I can't find anything.
  Here's my code:</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.util.Random;
  import javax.swing.*;
  
  public class Main extends JFrame {
  JLabel label = new JLabel("Enter a Yes or No question");
  JTextField field = new JTextField(12);
  JButton button = new JButton("Enter");
  
  public Main() {
      super("MAGIC 8 BALL");
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLayout(new FlowLayout());
      add(label);
      add(field);
      add(button);
  }
  
  public void actionPerformed(ActionEvent e) {
      String question = field.getText();
      int ball;
      Random r = new Random();
      ball = r.nextInt(20);
      String answer = ball;
      switch (ball) {
      case 0:
          System.out.println("It's certain");
          break;
      case 1:
          System.out.println("It's decidedly so");
          break;
      case 2:
          System.out.println("Without a doubt");
          break;
      case 3:
          System.out.println("Yes definitely");
          break;
      case 4:
          System.out.println("You may rely on it");
          break;
      case 5:
          System.out.println("Probably");
          break;
      case 6:
          System.out.println("Try again later");
          break;
      case 7:
          System.out.println("Better Not to Tell you");
          break;
      case 8:
          System.out.println("Cannot predict now");
          break;
      case 9:
          System.out.println("Cannot see reply right now");
          break;
      case 10:
          System.out.println("Concentrate and ask again");
          break;
      case 11:
          System.out.println("Don't count on it");
          break;
      case 12:
          System.out.println("My reply is no");
          break;
      case 13:
          System.out.println("Very doubtful");
          break;
      case 14:
          System.out.println("Outlook not so good");
          break;
      case 15:
          System.out.println("My sources say no");
          break;
      case 16:
          System.out.println("Yes");
          break;
      case 17:
          System.out.println("Signs point to yes");
          break;
      case 18:
          System.out.println("As I see it, yes");
          break;
      case 19:
          System.out.println("Yes definitely");
          break;
      }
  }
  }
  </code></pre>