FileDocCategorySizeDatePackage
ServiceBrowser.javaAPI DocExample1884Sat Jan 08 12:06:56 GMT 2005None

ServiceBrowser

public class ServiceBrowser extends Object

Fields Summary
JPanel
mainPanel
JComboBox
serviceList
ServiceServer
server
Constructors Summary
Methods Summary
public voidbuildGUI()

      JFrame frame = new JFrame("RMI Browser");
      mainPanel = new JPanel();
      frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
      
      Object[] services = getServicesList();
  
      serviceList = new JComboBox(services);
      frame.getContentPane().add(BorderLayout.NORTH, serviceList);

      serviceList.addActionListener(new MyListListener());     

      frame.setSize(500,500);
      frame.setVisible(true);

  
java.lang.Object[]getServicesList()

      
      Object obj = null;
      Object[] services = null;

      try {
         
         obj = Naming.lookup("rmi://127.0.0.1/ServiceServer");
         
      }
     catch(Exception ex) {
       ex.printStackTrace();
     }
     server = (ServiceServer) obj;
      
    
      try {
        
        services = server.getServiceList();
        
      } catch(Exception ex) {
         ex.printStackTrace();
      }
     return services;
        
   
voidloadService(java.lang.Object serviceSelection)

       try {
          Service svc = server.getService(serviceSelection);
          
          mainPanel.removeAll();
          mainPanel.add(svc.getGuiPanel());
          mainPanel.validate();
          mainPanel.repaint();
        } catch(Exception ex) {
           ex.printStackTrace();
        }
   
public static voidmain(java.lang.String[] args)

     new ServiceBrowser().buildGUI();