1 26 27 package DiningPhilosophers.explorer; 28 29 30 import javax.swing.JOptionPane ; 31 32 33 import org.omg.Components.CreateFailure; 34 import DiningPhilosophers.PhilosopherHome; 35 36 import org.objectweb.util.explorer.api.TreeView; 37 import org.objectweb.util.explorer.api.MenuItem; 38 import org.objectweb.util.explorer.api.MenuItemTreeView; 39 40 46 public class PhilosopherCreationAction 47 implements MenuItem 48 { 49 50 56 62 68 74 public int getStatus(TreeView treeView) { 75 return MenuItem.ENABLED_STATUS; 76 } 77 78 public void actionPerformed(MenuItemTreeView e) throws Exception { 79 String name = ""; 80 while (name != null && name.equals("")) { 81 name = JOptionPane.showInputDialog("Enter the philosopher's name:"); 82 } 83 if(name!=null){ 84 PhilosopherHome philosopherHome = (PhilosopherHome) e.getSelectedObject(); 85 philosopherHome._new(name); 86 } 87 } 88 89 } 90 | Popular Tags |