1 31 package org.objectweb.proactive.examples.readers; 32 33 import org.objectweb.proactive.core.config.ProActiveConfiguration; 34 35 public class AppletReader extends org.objectweb.proactive.examples.StandardFrame { 36 37 public ReadCanvas readerPanel; 38 private ReaderDisplay display; 39 private javax.swing.JComboBox policy; 40 41 42 public AppletReader(String name, int width, int height) { 43 super(name, width, height); 44 } 45 46 47 public static void main(String arg[]) { 48 ProActiveConfiguration.load(); 49 new AppletReader("Reader/Writer", 350, 300); 50 } 51 52 53 public void start() { 54 receiveMessage("Creating active objects"); 55 try { 56 display = new ReaderDisplay(this); 57 display = (ReaderDisplay)org.objectweb.proactive.ProActive.turnActive(display); 58 receiveMessage("Running..."); 59 } catch (Exception e) { 60 e.printStackTrace(); 61 } 62 } 63 64 68 protected javax.swing.JPanel createRootPanel() { 69 javax.swing.JPanel panel = new javax.swing.JPanel (new java.awt.BorderLayout ()); 70 readerPanel = new ReadCanvas(); 71 panel.add(readerPanel, java.awt.BorderLayout.CENTER); 72 73 javax.swing.JPanel pControls = new javax.swing.JPanel (new java.awt.BorderLayout ()); 75 pControls.add(new javax.swing.JLabel ("Synchronization Policy"), java.awt.BorderLayout.WEST); 76 policy = new javax.swing.JComboBox (new String []{"Even Policy","Priority to Writers","Priority to Readers"}); 77 policy.addActionListener(new java.awt.event.ActionListener () { 78 79 public void actionPerformed(java.awt.event.ActionEvent e) { 80 display.setPolicy(policy.getSelectedIndex()); 81 } 82 }); 83 pControls.add(policy, java.awt.BorderLayout.CENTER); 84 85 panel.add(pControls, java.awt.BorderLayout.SOUTH); 86 return panel; 87 } 88 } 89 | Popular Tags |