package interpreters; import javax.swing.JOptionPane; import java.awt.Color; import javax.swing.SwingUtilities; import painter.SPainter; import shapes.SCircle; public class interpreter2 { private void interpreter() { SPainter micro = new SPainter("Dot Thing",400,400); micro.setScreenLocation(0,0); SCircle dot = new SCircle(180); while(true) { String command = JOptionPane.showInputDialog(null,"Command?"); if(command==null) { command="exit"; } // user clicked Cancel if(command.equalsIgnoreCase("blue")) { micro.setColor(Color.BLUE); micro.paint(dot); } else if(command.equalsIgnoreCase("red")) { micro.setColor(Color.RED); micro.paint(dot); } else if(command.equalsIgnoreCase("green")) { micro.setColor(Color.GREEN); micro.paint(dot); } else if(command.equalsIgnoreCase("yellow")) { micro.setColor(Color.YELLOW); micro.paint(dot); } else if(command.equalsIgnoreCase("help")) { JOptionPane.showMessageDialog(null," Valid comments are :"+"RED|BLUE|GREEN|YELLOW|HELP|EXIT"); } else if(command.equalsIgnoreCase("exit")) { micro.end(); System.out.println("Thank You for viewing the dots..."); break; } else { JOptionPane.showMessageDialog(null, "Unrecognizable command:"+command.toUpperCase()); } } } public interpreter2() { interpreter(); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { new interpreter2(); } }); } }