1 31 package org.objectweb.proactive.examples.philosophers; 32 33 import org.objectweb.proactive.core.config.ProActiveConfiguration; 34 35 public class AppletPhil extends org.objectweb.proactive.examples.StandardFrame { 36 37 private String url; 39 private DinnerLayout theLayout; 40 private javax.swing.JPanel theLayoutPanel; 41 42 public AppletPhil(String name, int width, int height) { 43 super(name, width, height); 44 } 45 46 public static void main(String args[]) { 47 ProActiveConfiguration.load(); 48 AppletPhil phil = new AppletPhil("Philosophers", 450, 300); 49 phil.receiveMessage("Applet running..."); 50 if (args.length == 1) { 51 phil.setURL(args[0]); 52 } 53 phil.go(); 54 } 55 56 private void go() { 57 try { 58 60 theLayout = (DinnerLayout) org.objectweb.proactive.ProActive.turnActive(theLayout); 61 if (url != null) 62 theLayout.setNode(url); 63 66 org.objectweb.proactive.ProActive.waitFor(theLayout.init()); 67 theLayout.activateButtons(); 68 receiveMessage("Objects activated..."); 69 } catch (Exception ex) { 70 ex.printStackTrace(); 71 } 72 } 73 74 public void setURL(String url) { 75 this.url = url; 76 } 77 78 79 protected void start() { 80 } 81 82 89 90 protected javax.swing.JPanel createRootPanel() { 91 javax.swing.Icon imgArray[] = new javax.swing.Icon [5]; 93 try { 94 ClassLoader c = this.getClass().getClassLoader(); 95 imgArray[0] = new javax.swing.ImageIcon (c.getResource("org/objectweb/proactive/examples/philosophers/think.gif")); 96 imgArray[1] = new javax.swing.ImageIcon (c.getResource("org/objectweb/proactive/examples/philosophers/wait.gif")); 97 imgArray[2] = new javax.swing.ImageIcon (c.getResource("org/objectweb/proactive/examples/philosophers/eat.gif")); 98 imgArray[3] = new javax.swing.ImageIcon (c.getResource("org/objectweb/proactive/examples/philosophers/fork0.gif")); 99 imgArray[4] = new javax.swing.ImageIcon (c.getResource("org/objectweb/proactive/examples/philosophers/fork1.gif")); 100 } catch (Exception e) { 101 e.printStackTrace(); 102 } 103 theLayout = new DinnerLayout(imgArray); 105 return theLayout.getDisplay(); 106 } 107 } | Popular Tags |