1 package interpreters; 2 import java.awt.Color; 3 import javax.swing.JOptionPane; 4 import javax.swing.SwingUtilities; 5 import painter.SPainter; 6 import shapes.SCircle; 7 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 { 21 command = "exit"; 22 } 23 if (command.equalsIgnoreCase("blue")) 24 { 25 miro.setColor(Color.BLUE); 26 miro.paint(dot); 27 } 28 else if (command.equalsIgnoreCase("red")) 29 { 30 miro.setColor(Color.RED); 31 miro.paint(dot); 32 } 33 else if (command.equalsIgnoreCase("help")) 34 { 35 JOptionPane.showMessageDialog(null, "valid commands are: " 36 + "RED | BLUE | HELP | EXIT"); 37 } 38 else if (command.equalsIgnoreCase("exit")) { 39 miro.end(); 40 System.out.println("Thank you for viewing the dots ..."); 41 break; 42 } 43 else 44 { 45 JOptionPane.showMessageDialog(null, "Unreconizable command: " + command. toUpperCase()); 46 } 47 } 48 } 49 public Interpreter1() 50 { 51 interpreter(); 52 } 53 public static void main(String[] args) 54 { 55 SwingUtilities.invokeLater(new Runnable() 56 { 57 public void run() 58 { 59 new Interpreter1(); 60 } 61 }); 62 } 63 } 64