/home/ssingh6/NetBeansProjects/CS1/src/interpreters/Interpreter2.java
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package interpreters;
 7 import javax.swing.JOptionPane;
 8 import java.awt.Color;
 9 import javax.swing.SwingUtilities;
10 import painter.SPainter;
11 import shapes.SCircle;
12 /**
13  *
14  * @author ssingh6
15  */
16 public class Interpreter2 {
17 
18     private void interpreter()
19     {
20         SPainter micro = new SPainter("Dot Thing",400,400);
21         micro.setScreenLocation(0,0);
22         SCircle dot = new SCircle(180);
23         while(true)
24         {
25             String command = JOptionPane.showInputDialog(null,"Command?");
26             if(command==null) { command="exit"; } // user clicked Cancel
27             if(command.equalsIgnoreCase("blue"))
28             {
29                 micro.setColor(Color.BLUE);
30                 micro.paint(dot);
31             }
32             else if(command.equalsIgnoreCase("red"))
33             {
34                 micro.setColor(Color.RED);
35                 micro.paint(dot);
36             }
37             else if(command.equalsIgnoreCase("green"))
38             {
39                 micro.setColor(Color.GREEN);
40                 micro.paint(dot);
41             }
42             else if(command.equalsIgnoreCase("yellow"))
43             {
44                 micro.setColor(Color.YELLOW);
45                 micro.paint(dot);
46             }
47             else if(command.equalsIgnoreCase("help"))
48             {
49                 JOptionPane.showMessageDialog(null," Valid comments are :"+"RED|BLUE|GREEN|YELLOW|HELP|EXIT");
50             }
51             else if(command.equalsIgnoreCase("exit"))
52             {
53                 micro.end();
54                 System.out.println("Thank You for viewing the dots...");
55                 break;
56                 
57             }
58             else
59             {
60                 JOptionPane.showMessageDialog(null, "Unrecognizable command:"+command.toUpperCase());
61             }
62         }
63     }
64 
65     public Interpreter2()
66     {
67         interpreter();
68     }
69     public static void main(String[] args) {
70         SwingUtilities.invokeLater(new Runnable(){
71             public void run() {
72                 new Interpreter2();
73             }
74         });
75     }
76     
77 }
78