FileDocCategorySizeDatePackage
AppletBrowser.javaAPI DocJBoss 4.2.18715Fri Jul 13 21:02:14 BST 2007org.jboss.console.navtree

AppletBrowser

public class AppletBrowser extends JApplet
AdminTreeBrowser container for applets
see
org.jboss.console.navtree.AdminTreeBrowser
author
Sacha Labourey.
version
$Revision: 57191 $

Fields Summary
AdminTreeBrowser
treeBrowser
AppletAdminContext
ctx
public static final String
RIGHT_FRAME_NAME
protected String
sessionId
protected String
pmJmxName
Constructors Summary
public AppletBrowser()

   

      
               
   
Methods Summary
protected voidinitAppletParams()

      sessionId = getParameter("SessionId");
      if (sessionId != null)
         sessionId = "jsessionid=" + sessionId;
      else
         sessionId = "";

      this.pmJmxName = getParameter("PMJMXName");
      if( pmJmxName == null )
         pmJmxName = "jboss.admin:service=PluginManager";
   
protected voidinitComponents()

      javax.swing.JTree tree = treeBrowser.getTree();
      javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane(tree);
      
      scrollPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
      
      getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
      
      //getContentPane().add(tree, java.awt.BorderLayout.CENTER);
   
protected voidinitRefreshThread()

      try
      {         
         String strRefreshSec = getParameter("RefreshTime");
         if (strRefreshSec != null && !"".equals(strRefreshSec))
         {
            final long refresh = Long.parseLong(strRefreshSec);
            Thread t = new Thread ( new Runnable()
               {
                  public synchronized void run ()
                  {
                     long timeout = refresh*1000;
                     while (true)
                     {
                        try
                        {
                           this.wait(timeout);
                           treeBrowser.refreshTree(false);
                        }
                        catch (Exception displayed)
                        {
                           //displayed.printStackTrace();
                        }
                     }
                  }
               }
            );
            
            t.start();
         }
      }
      catch (Exception displayed)
      {
         displayed.printStackTrace();
      }      
   
public static voidmain(java.lang.String[] args)
Allow the applet to be run as an application: java -cp applet.jar org.jboss.console.navtree.AppletBrowser

param
args
throws
Exception

      JApplet applet = new AppletBrowser();
      applet.setStub(new MainAppletStub());
      JFrame frame = new JFrame("Administration Console");
      frame.getContentPane().add(applet);
      frame.setSize(600, 500);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      applet.init();
      applet.start();
      frame.setVisible(true);
   
public voidrefreshTree(boolean force)

      treeBrowser.refreshTree(force);
   
public voidstart()

      try
      {
         ctx = new AppletAdminContext ();
         
         initAppletParams();
         
         treeBrowser = new AdminTreeBrowser (ctx);
         
         initComponents ();
         
         initRefreshThread ();
         
      }
      catch (Exception e)
      {
         e.printStackTrace ();
      }