Interpreter1.java
1    /* This program is intended to paint different color dots in a window 
2     * 
3     * The commands that interpreter1 recognizes and responds to are: 
4     * BLUE: paint blue dot 
5     * RED: paint red dot 
6     * HELP: show a list of commands 
7     * EXIT: END PROGRAM 
8     */
9    package Interpreters;
10   import java.awt.Color;
11   import javax.swing.JOptionPane;
12   import javax.swing.SwingUtilities;
13   import painter.SPainter;
14   import shapes.SCircle;
15   public class Interpreter1 {
16      private void interpreter() {
17          SPainter marsh = new SPainter("Dots", 400, 400);
18          marsh.setScreenLocation(0, 0);
19          SCircle dot = new SCircle(180);
20          while (true) {
21              String command = JOptionPane.showInputDialog(null, "Command?");
22              if (command == null) {
23                  command = "exit";
24              } //user clicked on cancel
25              if (command.equalsIgnoreCase("blue")) {
26                  marsh.setColor(Color.BLUE);
27                  marsh.paint(dot);
28              } else if (command.equalsIgnoreCase("red")) {
29                  marsh.setColor(Color.RED);
30                  marsh.paint(dot);
31              } else if (command.equalsIgnoreCase("help")) {
32                  JOptionPane.showMessageDialog(null, "Valid commands are: "
33                          + "RED | BLUE | HELP | EXIT");
34              } else if (command.equalsIgnoreCase("exit")) {
35                  marsh.end();
36                  System.out.println("Thank you for the dots...");
37                  break;
38              } else {
39                  JOptionPane.showMessageDialog(null, "Command not understood please try again :P "
40                          + command.toUpperCase());
41              }
42          }
43   
44      }
45      //Painting stuff here ,-,
46       public Interpreter1() {
47          interpreter();
48       }
49       public static void main(String[] args) {
50           SwingUtilities.invokeLater(new Runnable() {
51               public void run() {
52                 new Interpreter1();
53               }
54           });
55       }
56   }
57