1 package interpreters; 2 3 import java.awt.Color; 4 import javax.swing.JOptionPane; 5 import javax.swing.SwingUtilities; 6 import painter.SPainter; 7 import shapes.SCircle; 8 9 public class Interpreter1 { 10 11 private void interpreter() { 12 13 SPainter miro = new SPainter("Dot Thing", 400, 400); 14 miro.setScreenLocation(0, 0); 15 SCircle dot = new SCircle(180); 16 17 while (true) { 18 String command = JOptionPane.showInputDialog(null, "Command?"); 19 if (command == null) { 20 command = "exit"; 21 } 22 if (command.equalsIgnoreCase("blue")) { 23 miro.setColor(Color.BLUE); 24 miro.paint(dot); 25 } else if (command.equalsIgnoreCase("red")) { 26 miro.setColor(Color.RED); 27 miro.paint(dot); 28 } else if (command.equalsIgnoreCase("help")) { 29 JOptionPane.showMessageDialog(null, "Valid commands are: " + "RED | BLUE | HELP | EXIT "); 30 } else if (command.equalsIgnoreCase("exit")) { 31 miro.end(); 32 System.out.println("Thank you for viewing the dots ..."); 33 break; 34 } else { 35 JOptionPane.showMessageDialog(null, "Unrecognizable command: " + command.toUpperCase()); 36 37 } 38 } 39 } 40 41 public Interpreter1() { 42 interpreter(); 43 44 } 45 46 public static void main(String[] args) { 47 SwingUtilities.invokeLater(new Runnable() { 48 public void run() { 49 new Interpreter1(); 50 } 51 }); 52 } 53 } 54