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 public class Interpreter1 { 9 private void interpreter(){ 10 SPainter miro = new SPainter("dot thing", 400,400); 11 miro.setScreenLocation(0,0); 12 SCircle dot = new SCircle(180); 13 while (true){ 14 String command= JOptionPane.showInputDialog(null,"command?"); 15 if (command == null) {command="exit";} 16 if(command.equalsIgnoreCase("blue")){ 17 miro.setColor(Color.blue); 18 miro.paint(dot); 19 } 20 else if (command.equalsIgnoreCase("red")){ 21 miro.setColor(Color.red); 22 miro.paint(dot); 23 } else if (command.equalsIgnoreCase("help")){ 24 JOptionPane.showMessageDialog(null,"valid commands are:"+ "RED|BLUE|HELP|EXIT"); 25 26 } else if (command.equalsIgnoreCase("exit")){ 27 miro.end(); 28 System.out.println("thankyou for viewing the dots..."); 29 break; 30 31 } else{ 32 JOptionPane.showMessageDialog(null,"unrecognizable command:"+ command.toUpperCase()); 33 } 34 } 35 36 } 37 public Interpreter1(){ 38 interpreter(); 39 } 40 public static void main(String[] args) { 41 SwingUtilities.invokeLater(new Runnable() { 42 @Override 43 public void run() { 44 new Interpreter1(); 45 } 46 }); 47 } 48 } 49