Ejemplo n.º 1
0
 public static void main(String[] args) {
   int radius = 500;
   SmileyModel test = new SmileyModel(radius, true);
   FirstSmileyPanel view = new FirstSmileyPanel(test);
   AAPCEventPrinter ep = new AAPCEventPrinter();
   test.addPropertyChangeListener(ep);
   JFrame frame = new JFrame("Smiley of DOOM!!!");
   Container container = frame.getContentPane();
   container.add(view);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(600, 600);
   frame.setVisible(true);
   int i = 0;
   while (true) {
     test.rotateEye(i);
     i += 10;
     if (i % 90 == 0) {
       test.changeSmile();
       test.setSmile(true);
       // test.setSize(radius+=20);
     }
     try {
       TimeUnit.MILLISECONDS.sleep(100);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
 }
Ejemplo n.º 2
0
 public void actionPerformed(ActionEvent e) {
   Commands c = Commands.valueOf(e.getActionCommand());
   switch (c) {
     case KOPFRADIUS_CHANGE:
       jtf = (JTextField) e.getSource();
       text = jtf.getText();
       if (text.isEmpty()) {
         model.setSize(model.getRadius() * 2);
       }
       try {
         number = Integer.parseInt(text);
       } catch (NumberFormatException ex) {
         ex.printStackTrace();
         number = 0;
         break;
       }
       if (number < 150) {
         model.setSize(150 * 2);
       } else if (number > 2000) {
         model.setSize(2000 * 2);
       } else {
         model.setSize(number * 2);
       }
       eyeSize = model.getEyeRad();
       break;
     case AUGENROLLEN_RECHTS:
       rollright = true;
       model.setRoll(true);
       model.rotateEye(model.getEyeAngel() + 10);
       break;
     case AUGENROLLEN_LINKS:
       rollright = false;
       model.setRoll(false);
       model.rotateEye(model.getEyeAngel() + 10);
       break;
     case SMILE_CHANGE:
       model.changeSmile();
       break;
     case HAPPY:
       model.setSmile(true);
       model.setEyeRad(eyeSize + 15);
       break;
     case SAD:
       model.setSmile(false);
       model.setEyeRad(eyeSize - 15);
       break;
     case PLUS:
       if (model.getRadius() + 10 > 2000) {
         model.setSize(2000 * 2);
       } else {
         model.setSize((model.getRadius() + 10) * 2);
       }
       eyeSize = model.getEyeRad();
       break;
     case MINUS:
       if (model.getRadius() - 10 < 150) {
         model.setSize(150 * 2);
       } else {
         model.setSize((model.getRadius() - 10) * 2);
       }
       eyeSize = model.getEyeRad();
       break;
   }
 }
Ejemplo n.º 3
0
 public Controler(SmileyModel model) {
   this.model = model;
   eyeSize = model.getEyeRad();
   rollright = true;
 }